Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2018-01-01
17:50 • Closed ticket [dd3b844fda]: oo::copy needs an optional namespace parameter p... artifact: 21257f1645 user: pooryorick
2017-06-07
09:31 • Ticket [dd3b844fda]: 4 changes artifact: e107f28782 user: dkf
06:22 • Ticket [dd3b844fda]: 4 changes artifact: 7bf3b5331d user: avl42
2016-11-23
21:42 • Ticket [dd3b844fda]: 3 changes artifact: fc336fa251 user: dkf
21:42 • New ticket [dd3b844fda]. artifact: 3b56eeec74 user: dkf

oo::copy needs an optional namespace parameter

Closed / Fixeddd3b844fdabdeae5fcb07f4a16d1c62ae5fa75acCreated 10 years agoUpdated 9 years ago
Descriptionwiki2016-11-23 21:42:28

Background

I 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 Request

Add 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.
oo::copy sourceObject ?targetObject? ?targetNamespace?

Implementation Notes

The basic functionality is already there at the C level; this is just exposing it to the Tcl level (and testing/documenting).
dkf Ticket [dd3b844fda]: 3 changes [History diff]2016-11-23 21:42:51
avl42 (claiming to be avl)plain2017-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.)
dkfhtml2017-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.

pooryorickwiki2018-01-01 17:50:40
Log in (anonymous is fine) to add a comment.