Tricky semantics of ranges & potentially numerous Phobos bugs
Jonathan M Davis
jmdavisProg at gmx.com
Wed Oct 17 08:55:07 PDT 2012
On Wednesday, October 17, 2012 11:17:08 Andrei Alexandrescu wrote:
> I think integration of pure streams within ranges is important and
> beneficial.
The problem isn't that it's a stream. The problem is that it reuses the buffer
that it returns, which is great for efficiency but horrible for algorithms which
actually try and use it as a range. Having to worry about front being
invalidated after a call to popFront would be a big problem - especially when
that's not at all normal behavior. And in many cases, you _can't_ code
algorithms in a way that supports that (e.g. if it needs to compare the result
of two subsequent calls to front). Having to worry about such ranges is just
going to complicate things even more. We already have enough issues with
special cases as it is - like save not being called because reference type
ranges are so rare, and least that's actually part of the range API, whereas
the idea that front could be invalidated really isn't.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list