foreach

monarch_dodra via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 13 07:25:19 PDT 2014


On Friday, 13 June 2014 at 09:29:25 UTC, Jonathan M Davis via 
Digitalmars-d wrote:
> I'd honestly rather see for(;;) {} removed than have foreach(; 
> 0..n) {} added.

Just out of curiosity, what is it you don't like about "for(;;)".

For what it's worth, I like using "for(;;)" a lot, because quite 
often, I find myself writing loops, but I don't know ahead of 
time *what* my conditions will be, nor *where* I'll place them. 
"for(;;)" is the first "rock" in my algorithm, which I fill and 
modify as I need while writing my code.

I tend to avoid "while(xxx)", for exactly this reason too: They 
tend to just end up having to be changed into a "for", so might 
as well just write "for(;xxx;)"


More information about the Digitalmars-d mailing list