Loop iterator - example.txt

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Sun Apr 30 10:32:32 PDT 2006


Sean Kelly wrote:
> Bruno Medeiros wrote:
>>
>> The remaining case, where you want to use continues and retries in the 
>> same for, well, I don't think it's a common enough case that makes it 
>> worth the introduction of a new keyword just some trivial syntactic 
>> sugar.
>> In fact, the very idea seems like a very awkward idiom to me. I would 
>> like to examine a real example, can someone post one?
> 
> Deleting selected members of a sequence:
> 
>     for( int i = 0; i < a.length; ++i )
>     {
>         if( isMatch( a[i] ) )
>         {
>             swap( a[i], a[$-1] );
>             a.length = a.length - 1;
>             retry;
>         }
>     }
> 
> 
> Sean

I was thinking of an example which used continues and retries in the 
same for, as yours can be cleanly rewritten as the example in my later post.
Anyway, Derek's example serves as a good example of the keyword's usage, 
but for "foreach", for "for" I'm still finding it a bit odd.


-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list