|Title:||oo::copy needs an optional namespace parameter|
|Submitter:||dkf||Created on:||2016-11-23 21:42:28|
|Subsystem:||35. TclOO Package||Assigned To:||dkf|
|Status:||Closed||Last Modified:||2018-01-01 17:50:40|
|Closed on:||2018-01-01 17:50:40|
BackgroundI was talking to Nathan Coulter at the Tcl conference and he was telling me about some of the things that are done in Rivet and NaviServer to get speed. In particular, he was doing horrible things to try to clone a namespace; it was a significant bottleneck. I mentioned that TclOO can clone namespaces (imperfectly) and speculated that oo::copy might be a useful tool. And indeed it might, except that existing code requires that the created namespace have a particular name (::request if I remember right) and oo::copy doesn't allow specifying the name of the created namespace, even though the underlying C API for object copying (Tcl_CopyObjectInstance) does.
Feature RequestAdd an extra optional argument to oo::copy to allow specifying the target object namespace. If omitted, the current behaviour should be used. If present, it must be in a form acceptable to Tcl_CreateNamespace and must not refer to an existing namespace; the name of the clone object's namespace will be the given value (instead of the default, arbitrary one). This will make oo::copy have two optional arguments, instead of the current single one.
Implementation NotesThe basic functionality is already there at the C level; this is just exposing it to the Tcl level (and testing/documenting).
pooryorick added on 2018-01-01 17:50:40:
dkf added on 2017-06-07 09:31:09:
It's not a single parameter because the object's command doesn't (usually) reside in its instance namespace, and they formally don't have a lot to do with each other.
avl42 (claiming to be avl) added on 2017-06-07 06:22:50:
Naive question: why not "targetNamespace::targetObject" as a single argument? (disclaimer "I've got no idea what I'm talking about" applies.)