You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The definition for substatements of a selection-statement is
for a selection-statement, any of its statements(but not its init-statement)
It clearly says that the statements that appeared in the grammar of a selection-statement are its substatement.
Instead, the definition for substatements of an iteration-statement is
for an iteration-statement, its contained statement (but not an init-statement).
Does it mean, in this example
while(false){
int a = 0;
}
The declaration statement is also the substatement of the iteration-statement? Because the declaration statement is contained by the iteration-statement? However, it seems not the intent of the standard. So, why the wording for describing the substatements for an iteration-statement and a selection-statement are different?
The text was updated successfully, but these errors were encountered:
For a selections statement, you can have things like if <stmt> else <stmt>, and both arms should be considered part of the substatement. I think that may be the reason for the different wording. Does that make sense?
For a selections statement, you can have things like if <stmt> else <stmt>, and both arms should be considered part of the substatement. I think that may be the reason for the different wording. Does that make sense?
Presumably, that would be the intent of the wording. However, there's no formal definition for the concept "contained statement". Hence, we only consider it in the English meaning here. IMO, that means all statements that be contained in a selection statement. int a = 0; is contained by while(false){ int a = 0; } I think it's vague here. Why not use its statement? That will be clear it refers to these statements which appear in the corresponding grammar. Such as: while ( condition ) statement Rather than refers to the statements contained by the statement.
jensmaurer
changed the title
The different definitions for the substatements of selection-statement and iteration-statement
[stmt.pre] Different definitions for the substatements of selection-statement and iteration-statement
Feb 5, 2021
The definition for substatements of a selection-statement is
It clearly says that the statements that appeared in the grammar of a selection-statement are its substatement.
Instead, the definition for substatements of an iteration-statement is
Does it mean, in this example
The declaration statement is also the substatement of the iteration-statement? Because the declaration statement is contained by the iteration-statement? However, it seems not the intent of the standard. So, why the wording for describing the substatements for an iteration-statement and a selection-statement are different?
The text was updated successfully, but these errors were encountered: