Semantics of toString

Philippe Sigaud philippe.sigaud at gmail.com
Wed Nov 11 09:08:52 PST 2009


Denis:
>BTW, save() is already implemented and used throughout the Phobos under a
different name - opSlice
 (i.e. auto copy = range[]). It's a bikeshed discussion, but why save() and
not opSlice(), or even clone()?

2009/11/11 Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>

> It can't be clone() because it doesn't clone. For example say you have a
> T[] - one would expect clone() actually copies the content. But using
> opSlice is a good idea.
>

I don't get it. Shouldn't save() copy the content?

Do you mean we could use opSlice() (the parameterless version) as a save
function and write "auto r2 = r1[];"?
But, again maybe I don't get something: for dyn. arrays (aka the range
archetype) opSlice is not a save, it's just an alias. So using opSlice
doesn't work for remembering positions with arrays.

   Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20091111/ac993663/attachment.html>


More information about the Digitalmars-d mailing list