Generality creep
Nick Sabalausky (Abscissa)
SeeWebsiteToContactMe at semitwist.com
Thu Apr 4 19:26:13 UTC 2019
On 3/28/19 1:05 PM, Andrei Alexandrescu wrote:
>>
>> Part of that is we've been cagey about defining copy and assignment
>> semantics of ranges in a simple and comprehensive manner. It seems to
>> me going with these is the right thing:
>>
>> * Input ranges are copyable and assignable, and have pointer semantics
>> (all copies refer to the same underlying position, and advancing one
>> advances all others).
>>
>> * Forward ranges are copyable and assignable, but distinct copies
>> refer to distinct positions in the range such that advancing one does
>> not advance the others.
>>
>> * We don't support other semantics.
>
> Forget to add - no more save(). We just use some sort of flag and simple
> introspection.
I say "Hooray!" to that!
I've long felt that 'save()' seemed a rather strange duplication of
assignment/copying (or perhaps more accurately, as Walter pointed out,
copy construction).
That seemed ugly enough in and of itself, but to make matters much
worse, this in turn left the semantics for passing and assigning ranges
underdefined and, in effect, needed to treated by algorithms as
undefined behavior. And THAT meant that nearly any occurrence of failing
to pass ranges by ref (surprisingly common in phobos, at least at the
time I noticed this) were much guaranteed to be a bug factory (In my
experience, this was especially problematic when working with output
ranges.)
More information about the Digitalmars-d
mailing list