Super-dee-duper D features

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Tue Feb 13 09:40:14 PST 2007


Sean Kelly wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Frits van Bommel wrote:
>>> Andrei Alexandrescu (See Website For Email) wrote:
>>>> Bill Baxter wrote:
>>>>> Yeh, I don't get it either.  How would that help me implement 
>>>>> merge() from merge sort for instance?
>>>>
>>>> Merge bumps the iteration in both collections conditionally. The 
>>>> form above bumps the iteration in the two collections 
>>>> unconditionally, until one is finished; then it continues with the 
>>>> other until that is finished.
>>>
>>> In other words, it doesn't :(.
>>
>> A need for loops iterating over multiple collections depending on 
>> arbitrary conditions will always be there. The point of extending 
>> foreach is to address the often-encountered case when you want to 
>> iterate over multiple collections simultaneously (e.g.: copy a 
>> collection to another), just like foreach itself is addressing the 
>> particular but frequent case of iterating one collection in a linear 
>> manner.
> 
> What about:
> 
>     foreach (i ; coll1) (j ; coll2)
>     {
>         if( true )
>             continue i;
>     }
> 
> ie. allow 'continue' to accept labels to specify which collection is 
> iterated.  A 'continue' without labels would iterate both.

I think that's a great idea, except that "continue to label" has the 
same syntax: http://digitalmars.com/d/statement.html#ContinueStatement

Andrei



More information about the Digitalmars-d mailing list