We can write an if
statement as
if (a == 5, b == 6, ... , thisMustBeTrue)
and only the last condition should be satisfiable to ent
For an if
statement, there is no real point in putting something into a comma expression rather than outside.
For a while
statement, putting a comma expression to the condition executes the first part either when entering the loop, or when looping. That cannot easily be replicated without code duplication.
So how about a s do
...while
statement? There we have only to worry about the looping itself, right? It turns out that not even here a comma expression can be safely replace by moving the first part into the loop.
For one thing, destructors for variables in the loop body will not have already been run then which might make a difference. For another, any continue
statement inside the loop will reach the first part of the comma expression only when it indeed is in the condition rather than in the loop body.