Le 16/10/2012 17:17, H. S. Teoh a écrit :
On Tue, Oct 16, 2012 at 05:01:57PM +0200, Tommi wrote:
On Tuesday, 16 October 2012 at 05:49:11 UTC, Jonathan M Davis wrote:
So, I don't really know what the right answer is, but I _really_
don't like the idea of having to worry about the result of front
changing after a call to popFront in every single function that ever
uses front.
Isn't the deeper underlying problem here the fact that there's no
generic way to make a deep copy in this language (does any language?)
Making a deep copy of front would be a clean solution. I don't know
how to implement this generic deep copying functionality though. For
example: what would be the semantics of deep-copying a range?
I don't think the problem here is whether we have a deep copy or not,
but that the semantics of ranges are not defined clearly enough. If we
clearly state, for example, that whatever is returned by .front must
persist beyond popFront(), then it would be up to the range to implement
the deep copy, e.g., return the .dup or .idup'd array instead of a
reference to an internal buffer.
It wouldn't be enough. Does several call to front recompute things ? See
http://d.puremagic.com/issues/show_bug.cgi?id=8803