RFC: Behavior of continue in do/while loops.

Downs default_357-line at yahoo.de
Wed Sep 12 08:55:27 PDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I 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_.
I know this is the same behavior as in C, but as somebody who never
encountered it before I can assure you, it's highly unintuitive.
The confusion here stems largely from the way a do/while loop looks -
the condition is found at the _end_ at the loop body, yet I expected
continue to jump to the _beginning_.
There is two questions I want to ask:
First, if you were starting a new language, should the behavior of
continue in that language match what I expected in this case?
(theoretical case)
And second, should the behavior be changed in the D programming
language, even though it _might_ conceivably break code that relies on
the current behavior? (practical case)

Looking forward to your comments,
 --downs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG6AvvpEPJRr05fBERAnfQAJ0UapoxtHQCtIfTerkFe3iUnTHXtACfTFj4
ennSYblhmnx1yOzb6izeCfs=
=kBA4
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list