Enhancing foreach
    Jonathan M Davis 
    jmdavisProg at gmx.com
       
    Wed Jan  9 15:14:59 PST 2013
    
    
  
On Wednesday, January 09, 2013 05:38:16 ixid wrote:
> A very minor change that would be elegant and easy for beginners:
> 
> foreach(i;5)
> //stuff
> 
> Allowing just a single number to mean the end point and a default
> starting point of zero is assumed, just as with iota it's
> possible to write it iota(5) or even 5.iota, it assumes unless
> otherwise specified that you mean 0 to be the starting point.
> Would this be a reasonable enhancement request for me to make or
> does it collide with something?
I would argue that the mistake is that iota(5) works. That's not at all clear, 
and
foreach(i; 5)
 //stuff
is no better. Regardless, all such an enhancement would do is save you a 
little bit of typing. It adds no actual functionality to the language, so I 
_really_ don't think that it makes sense to implement anything like that.
- Jonathan M Davis
    
    
More information about the Digitalmars-d-learn
mailing list