After the targetObject has been created and all definitions of its configuration (e.g., methods, filters, mixins) copied, the <cloned> method of targetObject will be invoked, to allow for customization of the created object such as installing related variable traces. The only argument given will be sourceObject. The default implementation of this method (in oo::object) just copies the procedures and variables in the namespace of sourceObject to the namespace of targetObject. If this method call does not return a result that is successful (i.e., an error or other kind of exception) then the targetObject will be deleted and an error returned.
The result of the oo::copy command will be the fully-qualified name of the new object or class.
oo::object create src oo::objdefine src method msg {} {puts foo} oo::copy src dst oo::objdefine src method msg {} {puts bar} src msg → prints "bar" dst msg → prints "foo"
Copyright © 2007 Donal K. Fellows
Licensed under Tcl/Tk terms
https://www.tcl.tk/man/tcl/TclCmd/copy.htm