Copy constructor in D. Why it is necessary to have it.

Bill Baxter wbaxter at gmail.com
Tue Sep 30 14:06:11 PDT 2008


On Wed, Oct 1, 2008 at 5:55 AM, bearophile <bearophileHUGS at lycos.com> wrote:
> Bill Baxter:
>> It has been pointed out though, that dup is a "shallow copy" in D's
>> built-in usage.  If you want a deep copy operation, there is no
>> precedent in the base language, I believe.  Clone is a good one to
>> standardize on for deep copies, I think.
>
> I see.
> Probably the more readable & intuitive names are "copy" and "deepcopy". But "dup" is already present, so it has to be accepted, I presume.
> What about "deepdup" for the deep version instead? :-)

Heh,  made me think .deeppoop when I first saw that.

> It's more easy to remember its meaning (and I presume it's not that commonly used to deserve a very short name).

I like clone.  It's used pretty commonly in other languages.  I'd
rather not follow up one slightly odd-ball name with an even more
bizarre one.  But it's not gonna be anything more than a convention
anyway, so you're free to name it .deepdup if you like in your
libraries.

--bb



More information about the Digitalmars-d mailing list