do-while loops
Denis Shelomovskij
verylonglogin.reg at gmail.com
Wed Dec 28 11:14:07 PST 2011
28.12.2011 16:29, bearophile пишет:
> One thing that I often find not handy in the design of do-while loops: the scope of their body ends before the "while":
>
>
> void main() {
> do {
> int x = 5;
> } while (x != 5); // Error: undefined identifier x
> }
>
>
> So I can't define inside them variables that I test in the while().
>
> This keeps the scope clean, but it's not nice looking:
>
>
> void main() {
> {
> int x;
> do {
> x = 5;
> } while (x != 5);
> }
> }
>
> Bye,
> bearophile
+1
I faced it a few days ago too. An enhancement request should be filled.
Even if it will be resolved as WONTFIX, at least we will know a reason.
More information about the Digitalmars-d-learn
mailing list