Taking a copy of an object
kris
foo at bar.com
Wed Aug 9 23:55:51 PDT 2006
Derek Parnell wrote:
> On Thu, 10 Aug 2006 00:30:15 -0400, Mikola Lysenko wrote:
>
>
>>Adding a virtual deep copy method to Object is a bad idea.
>
>
> ...
>
>
>>A different solution is to require each type to explicitly state if it
>>supports deep-copies at compile time.
>
> ...
>
>
>>If everyone adheres to this convention, the following templates to allow
>>anyone to test if a type is clonable at compile time - and easily perform
>>a clone.
>
>
> ...
>
>
>>For completeness, there is also a shallow copy or 'dup'
>>operation using the same technique.
>
>
> Yes. This is most of what I was trying to get across.
>
> The only problem is the phrase "If everyone adheres to this convention".
> That will never happen, people being as they are. This is why I'd like
> these capabilities to be supported by the compiler via the use of operators
> that invoke the associated 'op' function.
Yes; although "we", as a group, /could/ commandeer the opDup() and
opClone() method-names ourselves ~ it's surprising how having the
op-prefix can persuade people to comply with a convention, especially
when there's some potential that the compiler may catch up later :)
If we did start using these names, how might it conflict? Would opDup
potentially mean something different in the future? Or opClone? What
doth Walter say?
More information about the Digitalmars-d
mailing list