Super-dee-duper D features

Bill Baxter dnewsgroup at billbaxter.com
Tue Feb 13 14:59:36 PST 2007


Frits van Bommel wrote:
> 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?

Whoa!  I certainly hope so.  It hadn't even occurred to me that Andrei 
might mean this syntax can only be used for just two collections.  If 
that's the case then ... ick.

--bb



More information about the Digitalmars-d mailing list