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

bearophile bearophileHUGS at lycos.com
Tue Sep 30 13:55:12 PDT 2008


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? :-) It's more easy to remember its meaning (and I presume it's not that commonly used to deserve a very short name).

Bye,
bearophile



More information about the Digitalmars-d mailing list