Transience of .front in input vs. forward ranges

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Nov 5 20:34:06 PST 2012


On Tue, Nov 06, 2012 at 05:18:18AM +0100, Tommi wrote:
> I don't think this whole issue has anything to do with ranges. I
> think this is an issue of assuming that the symbol = means "copy
> what's on the right to what's on the left". When in reality, = could
> mean: (if what's on the right has reference semantics) "make what's
> on the left reference the same thing that the thing on the right
> references".
> 
> I think all range types should be allowed to return whatever they
> want from their front property. It's the responsibility of the user
> of the range to *actually* copy what front returns (if that's what
> he intends), instead of assuming that = means copy.
[...]

The problem is that you can't do this in generic code, because generic
code by definition doesn't know how to copy an arbitrary type.  Unless
we introduce a standardized deep copy operation to D, like a .clone
method that all copyable types implement, this solution isn't really
viable.


T

-- 
The computer is only a tool. Unfortunately, so is the user. -- Armaphine, K5


More information about the Digitalmars-d mailing list