View · Search · Index
No registered users in community xowiki
in last 10 minutes

RE: [Xotcl] XOTcl / Tcl Namespace issues

From: Schofield, Bryan \(GE Transportation\) <"Schofield,>
Date: Fri, 22 Oct 2004 16:51:41 -0400

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_at_alice.wu-wien.ac.at
> [mailto:xotcl-bounces_at_alice.wu-wien.ac.at]On Behalf Of Adam Turoff
> Sent: Friday, October 22, 2004 4:21 PM
> To: xotcl_at_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_at_alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>