Super-dee-duper D features

Sean Kelly sean at f4.ca
Tue Feb 13 09:13:41 PST 2007


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.


Sean



More information about the Digitalmars-d mailing list