Should range foreach be iterating over an implicit copy?

Jonathan M Davis jmdavisProg at gmx.com
Thu May 17 08:42:04 PDT 2012


On Thursday, May 17, 2012 11:05:46 Steven Schveighoffer wrote:
> Hm... proposal:
> 
> foreach(e; ref r)
> {
> }
> 
> equates to your desired code.  Would this help?

Or you could just do

for(; !r.empty; r.popFront())
{
    auto e = r.front;
}

I really don't think that that's a big deal. I don't think that the language 
change would be worth having yet another thing in the language to remember, 
particularly when it's so easy to just use for to do the job.

- Jonathan M Davis


More information about the Digitalmars-d mailing list