Taking a copy of an object

Derek Parnell derek at nomail.afraid.org
Fri Aug 4 00:01:12 PDT 2006


On Thu, 03 Aug 2006 23:47:47 -0700, kris wrote:

> Does deep-copy really need an operator? I have to wonder whether a 
> simple naming-convention would do the trick instead  ... that way, you'd 
> never have a /default/ deep-copy, and usage mistakes would produce a 
> most welcome compile-time error.

I'm not asking for a default deep copy. If you haven't defined one then its
a compile time error. How would a function/method work with arrays as .dup
only does a shallow copy. And how would it work in templates that use basic
types? An operator overcomes these issues by letting the compiler know what
the coder's intentions are and generate code accordingly. This could never
work 100% with a "naming-convention" as it is no compiler enforced.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
4/08/2006 4:57:48 PM



More information about the Digitalmars-d mailing list