forward ranges must offer a save() function
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Sat May 30 11:20:13 PDT 2009
bearophile wrote:
> Andrei Alexandrescu:
>> If we want to allow people to create ranges that are classes (as opposed
>> to structs) the requirement for a save() function is a must. This is
>> because copying class ranges with
>> Range copy = original;
>> only creates a new alias for original; the two share the same state.
>
> Do you mean a function to be called with the "dup" attribute?
> Maybe such method can be called dup()?
Except as I understand it save() is only supposed to save the iteration state,
not duplicate the elements being iterated over. So it has different semantics
that dup. For arrays, the definition would be something like this:
T[] save(T)(T[] arr) { return arr; }
(presumably implemented in std.range or something)
More information about the Digitalmars-d
mailing list