[Xotcl] NX objects and namespaces
Stefan Sobernig
stefan.sobernig at wu.ac.at
Thu Dec 29 21:06:24 CET 2022
Hi Maksym!
> namespace eval testNameSpace {
>> aClass create a_obj1
>> a_obj1 print
>> bClass create b_obj1 -pr a_obj1
>> }
tl;dr
You need to pass a fully-qualified object (command) name as an argument:
namespace eval testNameSpace {
set a_obj1_fq [aClass create a_obj1]
a_obj1 print
bClass new -pr [namespace which a_obj1]
bClass new -pr $a_obj1_fq
}
For this purpose, you may capture the fully-qualified object name as the
result of the create/new call via a variable (a_obj1_fq); or, you may
use [namespace which] to capture the namespace context.
In Tcl, and Tk, the call site is made responsible for resolving or
capturing the namespace context; and not the callee. Think of [namespace
code ...] and friends. In general, for the callee, there will be
ambiguity when reconstructing the original call site, in presence of
command traces or different [namespace path ...] settings (or, filters
and mixins in XOTcl/ NX); or combinations thereof.
HTH, and Happy New Year to you too,
Stefan
More information about the Xotcl
mailing list