Super-dee-duper D features

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Tue Feb 13 10:27:19 PST 2007


Andrei Alexandrescu (See Website For Email) wrote:
> Sean Kelly wrote:
>> 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

Does that really matter? The compiler knows whether 'i' is a label or a 
loop variable (presumably it can't be both at the same time?) so it 
knows what to do. Note that the current "continue to label" wouldn't 
help here since there's only one statement for a "double" iteration. So 
the most natural way to specify which loop to continue would be to 
specify the variable.


By the way, would the new loop syntax allow more than two collections to 
be simultaneously iterated?
That would indicate the need for a "continue i, j" as well, to specify 
multiple variables.
On the other hand, with your proposed "continue foreach" clauses after 
the main loop that would also require an exponential number of those 
clauses for different sets of collections running out if you want to 
handle all cases...



More information about the Digitalmars-d mailing list