Do we need "foreach"?

BCS ao at pathlink.com
Sun Apr 27 13:53:41 PDT 2008


Reply to Bill,

> Just started wondering why we really need the foreach keyword.
> 
> These two
> 
> for( x ; y ; z )
> 
> for( x ; y )
> 
> do no seem to be ambiguous to me.  You do need some lookahead, but I
> think D has some constructs like that already.
> 
> If we're looking to get rid of keywords it seems like a candidate.  I
> already mistakenly type "for" when I mean "foreach" fairly often.
> 
> --bb
> 

I think the syntax of for is already strange enough:

int i=0;
for(for(int j=0; j<10; i+=(j++)) if (i<0) break; i; i--) somthing();





More information about the Digitalmars-d mailing list