On 12/28/2011 02:29 PM, bearophile wrote:
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

I fully agree, but why does this go to D.learn?

Reply via email to