-
Notifications
You must be signed in to change notification settings - Fork 771
[basic.scope.block] p1 The note should be as a normative rule #4841
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
Comments
I disagree there is a need to clarify this normatively; I think the note is good enough for directing the reading here. @opensdh, any thoughts on this? |
If there is no normative rule, we could say the compound-statement of the selection statement can introduce two blocks, please note the wording Each, a compound-statement of the selection statement is both the substatement and the compound-statement itself, which satisfies the second bullet and the last bullet. |
To stress the opinion, please consider this example if(int a = 1)
if(int a = 0){} The declaration of |
I agree with @jensmaurer. A statement that matches two bullets doesn't produce two scopes; it just produces one scope for two different reasons. (It might be more reasonable to read it as two scopes if "and" separated the bullets, but even then there's only one object to have this property.) It's true that the |
If the second |
@opensdh: The concern is the treatment of these two examples:
#1 combines the "selection statement" and "substatement" bullets of [basic.scope.block] p1 and is ok (according to gcc and clang). #2 combines the "substatement" and "compound-statement" bullets of [basic.scope.block] p1 and is ill-formed. I can't reconcile the different treatment of #1 and #2 by the compilers with the normative wording we're looking at. To make that work, the model for #1 needs to be |
@jensmaurer After the above fix. I think we could add "or, if not that" into the end of each item in [basic.scope.block] p1, which will make that "just produces one scope for two different reasons." more clear. |
For this issue. We might say
This might clarify this issue. Since the compound statement itself as the substatement of a selection statement is the same statement, it introduces only one scope. |
I still don't see the need to do anything here: a list of "every Fibonacci number or cube less than 100" doesn't include 8 twice and 1 three times. |
Because, either Fibonacci number or cube, it has a clear mathematical definition and formulation from which each value arises. Back to natural language, consider this case
Assume a person has an apple and a banana, the group should get two scores because the person satisfies two. It wouldn't happen that the group IMO, the application of the bullet is equivalent to for(auto i : list){ // list is we defined
if(statement.has(i) == true){
statement.introduces_block++;
}
} |
Isn't that note should be phrased as a normative rule? My proposal is that
The substatement is a compound-statement, hence the second bullet does not apply but the last bullet does, which means the substatement only introduced one block scope.
The text was updated successfully, but these errors were encountered: