Taking a copy of an object

Lionello Lunesu lio at lunesu.remove.com
Thu Aug 3 02:56:45 PDT 2006


"Derek Parnell" <derek at nomail.afraid.org> wrote in message 
news:4war8mij9m44$.1xwxnpe32ro4e$.dlg at 40tude.net...
> Currently there doesn't seem to be any standard D mechanism (read:
> operator) to take a copy of an object. So are there any suggestions for a
> name that we can all agree on; one that might become an unofficial
> standard?
>
> For arrays we have the 'dup' property but for objects there is nothing 
> that
> the compiler assumes. I'm partial to 'onDup' or 'onCopy', and maybe even a
> 'onDeepCopy' as an additional function.

What's stopping you from using "dup" as the name?

#class Test {
#  Test dup() {
#    return new Test;
#  }
#}
#void main() {
#  Test t = new Test;
#  Test a = t.dup;
#}

L. 





More information about the Digitalmars-d mailing list