do-while loops

Timon Gehr timon.gehr at gmx.ch
Wed Dec 28 12:37:56 PST 2011


On 12/28/2011 09:32 PM, Alex Rønne Petersen wrote:
> On 28-12-2011 18:50, Timon Gehr wrote:
>> On 12/28/2011 06:42 PM, bearophile wrote:
>>> Timon Gehr:
>>>
>>>> I fully agree, but why does this go to D.learn?
>>>
>>> Because I think there's no hope to see this situation changed :-)
>>>
>>> Bye,
>>> bearophile
>>
>> Why? The only D code that would get broken would be code that uses a
>> global variable in the loop condition of the same name as a do loop
>> local variable.
>
> That's still a bit of a risk to take for such a small change, IMHO.
>
> - Alex

Well, do loops are the least frequently used looping constructs. Also, 
if you actually have code like the following

import foo; // defines global symbol 'x'

void main(){
     do {
         int x;
         // ...
     }while(x<2);
}


It is likely that it is actually buggy because the programmer assumed 
lookup would work differently.


More information about the Digitalmars-d-learn mailing list