State: Final Type: Project Tcl-Version: 8.6 Vote: Done Post-History: Author: Donal K. Fellows <firstname.lastname@example.org> Created: 13-Feb-2012 Keywords: Tcl, TclOO, copy, clone Implementation-URL: https://core.tcl.tk/tcloo/timeline?r=development-rfe3485060
This TIP proposes a mechanism whereby an object or class can provide additional control over how it gets copied to a new one by the oo::copy command.
I always knew that TclOO's oo::copy command was not particularly complete, in that only the C-level state was copied. The vast majority of state associated with an object (notably including its variables) was not copied on the grounds that the caller of oo::copy could do that for themselves. However, this has not proved particularly workable in practice once someone actually started to use the mechanism. It turns out that the callers of oo::copy expect a full copy of the object to be created.
This is quite challenging because some things associated with an object are tricky to copy correctly. For example, if an object has a number of Tk widgets under its control, or has timer callbacks set up, these are very challenging for a generic object copying scheme to detect (and generic copying of Tcl commands is difficult anyway). Fortunately, we already have a mechanism for handling such per-object variation: methods.
I propose that the oo::copy command will internally call the newly
Furthermore, a default implementation of the
See the "development-rfe3485060" branch of the tcloo repository: https://core.tcl.tk/tcloo/timeline?r=development-rfe3485060
This document has been placed in the public domain.