Proposal of a general do-while loop

Chris Nicholson-Sauls ibisbasenji at gmail.com
Sun Jul 22 09:07:51 PDT 2007


Rioshin an'Harthen wrote:
> "Charles D Hixson" <charleshixsn at earthlink.net> kirjoitti viestissä 
> news:f7t5ki$1mn0$1 at digitalmars.com...
>> I'd prefer the Ada-esque
>>      exit when (pos == string::npos);
>> but that means introducing new key words (more than just "loop").  
>> OTOH, I guess there's nothing wrong with having an un-parameterized 
>> "do" instead of loop, as in:
>>    do
>>    {  ... do stuff ...
>>       when(condition) break;
>>    }
>> in the case the "when" is semantically the same as an if, but it 
>> clarifies what's going on.  One could limit it's use to "only usable 
>> within a do loop".  But I would prefer the syntax of either:
>>       exit when (condition);
>> or
>>       break when (condition);
>> as I feel that these are clearer.
> 
> I'd say no to a new keyword just for this.
> 
> However, a syntax like
> 
>    break if (condition);
> 
> would, in my opinion, be better than
> 
>    if (condition) break;

I sit back and watch as D slowly evolves into Ruby... ;)

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list