Scott Gargash schrieb:
xotcl-bounces@alice.wu-wien.ac.at wrote on 03/19/2006 05:32:31 AM:
On 19 Mar 2006, at 14:09, Scott Gargash wrote:
xotcl-bounces@alice.wu-wien.ac.at wrote on 03/19/2006 04:08:40 AM:
On 19 Mar 2006, at 00:12, Scott Gargash wrote:
When would you need the namespace of the object?
I have only ever needed the namespace of an object which attaching traces to variables (f.ex. with Tk), but for that it is, unfortunately quite necessary.
I haven't used it yet, but doesn't the "trace" method handle this?
No. Some tk widgets map their values to Tcl variables. Other similar interfaces exist. It is handy to map them to an instance variable but for that it is necessary to have the namespaced version available.
Snit has a "myvar" method that returns the fully qualified name of a snit member variable. Perhaps something similiar (a method that returned a "reference" to an instance variable) would be useful in XOTcl?
well, without trying it out. variable_reference could look like:
Object instproc variable_reference name { my requireNamespace return [self]::$name }
in many situations, these fully qualified variable references are not needed, since e.g. the forwarder allows variable names to be used in scope of an object, such that e.g.
obj set x 100 obj lappend y 1 2 3
does the right thing (interpret variable references x and y in the obj scope), no matter whether obj has a object-specific namespace or not. It would be rather painful to write
obj lappend [obj variable_reference y] 1 2 3
These forwarders are registered during startup via:
foreach cmd {array append lappend trace eval unset} { ::xotcl::Object instforward $cmd -objscope }
-gustaf neumann