digitalmars.D - Re: Behavior of continue in do/while loops.
- Robert Fraser (3/17) Sep 12 2007 I like the "goto do"/"goto while" option. It's congruent with "goto case...
Downs Wrote:I never knew that (I rarely use do/while); I would have assumed it does another iteration of the loop. I agree that this is unintuitive to me, but others seem to think this is the right behavior and C compatibility is important so it should probably be left as-is."Downs" wroteI just came upon the interesting fact that using the "continue" statement in a do { } while() loop does not, in fact, continue with the next loop, but instead continues with the _condition_.miller[] came up with two good alternatives over in #D 1) forbidding continue in do/while and replacing it with continue do/continue while, or 2) adding goto do/goto while statements. The first one has the advantage of making it totally impossible for a newcomer to trip on this, while the second one has the advantage of not breaking existing code. Whaddya think? --downsI like the "goto do"/"goto while" option. It's congruent with "goto case"/"goto default".
Sep 12 2007