On Wednesday, 16 May 2012 at 21:40:39 UTC, Andrei Alexandrescu wrote:
On 5/16/12 4:37 PM, Nick Sabalausky wrote:
One counter-argument that was raised is that TDPL has an example on page 381 that indicates foreach iterates over an implicit copy. I don't have a copy handy ATM, so I can't look at it myself, but I'd love to see Andrei weigh in on this: I'm curious if this example in TDPL made that copy deliberately, or
if the full implications of that copy were just an oversight.

It is deliberate and the intent is that millions of programmers used to foreach from other languages don't scream "where is my range???"

Andrei

I think this is the correct behavior as well. Otherwise, we'd have to take extra care when writing generic code to ensure it doesn't consume the range but doesn't attempt to call .save on non-range types.

Reply via email to