I think you've stumbled on the namespace resolution bug that appeared with 1.3.0. Gustaf & Uwe have been working on fix and appear to close to releasing a new version. I'm testing a 1.3.3 version of XOTcl for Gustaf now. I added one more combination to your test: inner::Inner inner::i2 and I get the following results:
In :: o -> GLOBAL EXAMINE i -> inner examine inner::i2 -> inner examine
In ::inner o -> GLOBAL EXAMINE i -> inner examine inner::i2 -> inner examine
Which seems more inline to what you were expecting to see. Try this test version of XOTcl and see if you get better results. I'm sure the XOTcl guys would appreciate the extra testing anyway. http://media.wu-wien.ac.at/download/xotcl-1.3.3.tar.gz
Hope that helps. -- bryan
-----Original Message----- From: xotcl-bounces@alice.wu-wien.ac.at [mailto:xotcl-bounces@alice.wu-wien.ac.at]On Behalf Of Adam Turoff Sent: Friday, October 22, 2004 4:21 PM To: xotcl@alice.wu-wien.ac.at Subject: [Xotcl] XOTcl / Tcl Namespace issues
Hi,
Can anyone explain why this program:
package require XOTcl namespace import xotcl::* proc ns {} {return "global"} proc examine {} {puts "[ns] EXAMINE"} Class Outer Outer instproc test {} {return [examine]} namespace eval inner { proc ns {} {return "inner"} proc examine {} {puts "[ns] examine"} Class Inner Inner instproc test {} {return [examine]} } Outer o o test inner::Inner i i test namespace eval inner { ::o test ::i test }
produces this output:
global EXAMINE global EXAMINE inner examine inner examine
I've defined the class 'Inner' within the namespace 'inner'. I'd expect that proc in methods defined within that namespace should first look within that namespace before looking in the global namespace. Instead, they look in the namespace currently in use when a method call is made. (Note how ::o test picks up the definition of inner::examine when invoked from the inner namespace.)
This is the opposite behavior of how Tcl proc calls work -- when I land on inner::examine, the [ns] is actually shorthand for inner::ns, not ::ns.
I'm guessing there's a good reason for this behavior, but I can't seem to find it in the docs.
Thanks,
-- Adam _______________________________________________ Xotcl mailing list Xotcl@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
On Fri, 22 Oct 2004 16:51:41 -0400, Schofield, Bryan (GE Transportation) bryan.schofield@trans.ge.com wrote:
I think you've stumbled on the namespace resolution bug that appeared with 1.3.0. Gustaf & Uwe have been working on fix and appear to close to releasing a new version. I'm testing a 1.3.3 version of XOTcl for Gustaf now.
Whoops. Sorry. I'm using 1.2.0.
-- Adam
On Friday 22 October 2004 22:51, Schofield, Bryan (GE Transportation) wrote:
I think you've stumbled on the namespace resolution bug that appeared with 1.3.0.
actually, what adam points out was the xotcl behavior before 1.3.*. Earlier versions used always the current namespace for instprocs/procs, which is different from the standard tcl behavior, and has as well some more disadvantages for packages.
The bug that Michael Heca came up with (alloc bug) was a consequence of changing the old behavior. The exists bug that Attila came up with was in since the first xotcl versions.
All these issues are solved in the current testing version. We have still one complex issue to double check; if everything goes well, we should be able to release 1.3.3 next week.
-gustaf