All higher-order ranges in Phobos should not cache their element values. Such known ranges are: std.algorithm.Map and std.range.Sequence.
A Cached range should be introduced to make up for the loss.
Comment #1 by andrei — 2013-02-26T08:56:37Z
Hm, I think things are fine as they are, though I agree with the consistency argument. Agree to close?
Comment #2 by tomeksowi — 2013-02-26T12:28:04Z
The argument was the least about consistency, I recall caching got in the way when the mapped to element was:
- used <= 1 times
- trivial to calculate (faster than read/write)
- manually allocated (harder to anticipate destruction)
Plus, front/back vs. opIndex poses problems of their own.
Why the obligation to cache?
Comment #3 by hsteoh — 2014-11-17T03:06:51Z
Does this problem still occur? Over the last little while, many ranges have been rewritten to not cache their elements by default (unless there was reason to do so). Are there any specific ranges that cache .front in a problematic way? If not, can we close this bug?
Comment #4 by dmitry.olsh — 2014-11-17T20:58:06Z
Sequence still has cache, I'm not sure to what extent it's a problem.
Comment #5 by peter.alexander.au — 2015-01-02T10:52:26Z