Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stmt.while] no rewrite rule for non-variable condition case #2008

Closed
zygoloid opened this issue Apr 2, 2018 · 1 comment
Closed

[stmt.while] no rewrite rule for non-variable condition case #2008

zygoloid opened this issue Apr 2, 2018 · 1 comment
Assignees

Comments

@zygoloid
Copy link
Member

zygoloid commented Apr 2, 2018

In [stmt.while], we say:

A while statement whose condition is an initialized declaration of some variable t is equivalent to

label:
{
  condition ;
  if (t) {
    statement
    goto label;
  }
}

But fail to give any rewrite rule for the other kind of while statement. The result is both redundant and underspecified.

We could replace this with:

A while statement is equivalent to

label:
if (condition) {
  statement
  goto label;
}

... and make the wording simpler, less redundant, and more complete.

(Open question: is it useful to retain the braces around the outside of the if-statement in order to make it obvious that an else cannot bind to a while?)

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 2, 2018

Yes on both counts -- the simplification seems obvious in retrospect, and keeping the "else" part clear is valuable (especially given the notorious absence of a "while-else" construct in C++).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants