[Xotcl] Error or normal behavior?
Victor Mayevski
vitick at gmail.com
Wed Dec 8 07:35:05 CET 2010
Thank you Gustaf,
I guess I just expected that things will be automatically tracked no
matter in which namespace I invoked the nx::Class command. I have not
used xotcl::Class before that's why I never seen this behaviour. The
namespace "nx" is so short so it made it very convenient to just enter
"nx::Class" on command line instead of using "namespace import".
Nevertheless, it was very educational. Thanks again.
On Tue, Dec 7, 2010 at 9:39 PM, Gustaf Neumann <neumann at wu-wien.ac.at> wrote:
> On 08.12.10 05:40, Victor Mayevski wrote:
>>
>> It came to my attention that [namespace import -force nx::*] is a
>> requirement and not an option, otherwise things don't work right.
>> Example:
>>
>> nx::Class create C
>> C method init args {puts [self]; next}
>> C create c
>> #error, commands "self" and "next" do not exist, but if I first do
>> [namespace import -force nx::*], everything works fine.
>
> well, if i take the first sentence literally, this is not true.
> there are several options:
>
> if one uses a plain tcl shell, one can use
>
> a)
> package req nx
>
> nx::Class create C
> C method init args {puts [nx::self]; nx::next}
> C create c
>
> b)
> package req nx
> namespace path nx
>
> nx::Class create C
> C method init args {puts [self]; next}
> C create c
>
> c)
> package req nx
> namespace import nx::*
>
> nx::Class create C
> C method init args {puts [self]; next}
> C create c
>
> Concerning (c): there is no need to use "-force", except
> these commands were already imported (e.g. from some
> other package).
>
> One can use alternatively the "nxsh" (tcl-file, which does a
> package req nx
> namespace import nx::*
> automatically) and then in the script file just
>
> nx::Class create C
> C method init args {puts [self]; next}
> C create c
>>
>> This is not how I thought the namespaced commands should work. Is this
>> a feature or a bug? If not a bug, then it needs to be clearly
>> documented.
>
> I don't understand, what you expected. If you use just (a)
> then Tcl has no indication, what "self" or "next" should be used.
> For unprefixed names, Tcl requires to have to use either
> "namespace import" or "namespace path".
>
> The behavior is the same as in XOTcl 1. XOTcl/nx do not play
> any magic games with namespaces, they just use the standard
> tcl behaviour.
>
> -gustaf neumann
>
>
>
>
>
> _______________________________________________
> Xotcl mailing list
> Xotcl at alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>
More information about the Xotcl
mailing list