During this answer, our beloved Jon Skeet considers the case that do {} while ()
requires a statement-terminator because while()
requires a statement-body, and proceeds to exemplify that:
while (true);
(empty statement) orwhile (true) {}
(block statement)
...would be valid.
Things are quite straightforward with the second example; the while-loop executing the compound (block) statement ({}
), which is empty.
The first example however, together with Skeet's description, sparked an interesting question to me:
Does the ;
in while(true);
(or any other iteration statement) terminate the while
(/statement) itself (in some sense), or does it terminate an actual invisible empty statement between )
and the terminator?