Maybe we don't need foreach ;-)

Walter Bright newshound at digitalmars.com
Mon Oct 30 23:47:41 PST 2006


Bill Baxter wrote:
> Assuming you mean literally a b and c, it's pretty clear it's got to be 
> a foreach that was intended.  There's no reason to stick a variable in 
> either the first or last clause of a standard for.

There is if a and b are function names.


> Here's a example where the intent really isn't obvious:
> 
>    for (int a; b;)
>    for (int a; b)
> 
> Anyway, given that
> * I myself have been guilty of using ',' where I meant ';' in for loops,
> * 'in' can't be used in place of ';' due to syntactical ambiguities,
> 
> I agree that it's safer and better to have foreach separate.
> 
> --bb



More information about the Digitalmars-d mailing list