On 10/7/2010 07:24, Steven Schveighoffer wrote: > First, let me discuss why I don't like save.
... > So my question is, what is the point of save? The whole point is for > this last class of ranges, so they can implement a way to copy the > iteration position in a way that isn't doable via simple assignment. > But there *AREN'T ANY* of these ranges in existence. Why do we have a > feature that is littered all over phobos and any range that wants to be > more than a basic imput range when the implementation is return this; ? Let me add two reasons to that list. First, I expect that forgetting to call 'save' is or will be a very common bug. There's no way to detect it at compile time, and when the code is used with a range with a trivial 'save', the code will work as expected. The bug will only be triggered by a range with a non-trivial 'save'. Therefore ranges with non-trivial 'save' should be considered error-prone and should not be used. Second, it is in fact fairly easy to wrap a range with a non-trivial 'save' in a range with a trivial 'save', using a copy-on-write strategy. So if there /were/ any ranges with non-trivial 'save', it would be easy enough to rewrite them to eliminate the non-trivial 'save'. Eliminating 'save' makes ranges a lot easier and safer for range users, at a minor cost for range writers. Since range users greatly outnumber range writers, this seems like an overwhelmingly good trade-off. -- Rainer Deyke - [email protected]
