Should range foreach be iterating over an implicit copy?

Jesse Phillips jessekphillips+D at gmail.com
Wed May 16 20:26:08 PDT 2012


On Wednesday, 16 May 2012 at 21:37:54 UTC, Nick Sabalausky wrote:
> A small debate has broken out over on D.learn (
> http://forum.dlang.org/thread/jovicg$jta$1@digitalmars.com#post-jovicg:24jta:241:40digitalmars.com 
> )
> that I thought I should move here.

I am in agreement, a value type rage is confusing to use

http://d.puremagic.com/issues/show_bug.cgi?id=7067

I don't agree with Andrei that we want to stop the "hey, where'd 
my range go" because we spend so much effort to get that to be 
expected behavior (and it is). The hybrid array really doesn't 
help, but I wouldn't want it changed.

If .save is not called on the range then the expectation is that 
it will be consumed. It is clear that calling a function with a 
value type would likely mean it won't be consumed, but that is 
the odd case, the expectation is that the range would be consumed.

And this leads to what is suggested in the referenced bug, a 
wrapper to prevent an implicit forward range.


More information about the Digitalmars-d mailing list