On Friday, 7 September 2012 at 18:15:00 UTC, Steven Schveighoffer
wrote:
Well, this does work. But I don't like that the semantics
depend on whether the value is an rvalue or not.
Note that even ranges that are true input ranges (i.e. a file)
still consume their data, even as rvalues, there is no way
around it.
-Steve
Yes, but that is another issue, it is a "copy" vs "save" semantic
issue. In theory, one should assume that *even* with pass by
value, if you want your range to not be consumed, you have to
call "save". Most ranges are value types, so we tend to forget
it. std.algorithm had a few save-related bugs like that as a
matter of fact.
But, contrary to post 1, that is not the actual issue being fixed
here. It is merely a "compile with unnamed" fix:
formattedRead(file.save, ...)
And now it compiles fine. AND the range is saved. That's it.
Nothing more, nothing less.
...
That's *if* file provides "save". I do not know much about
file/stream handling in D, but you get my "save" point.