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

Re: [Xotcl] Error or normal behavior?

From: Victor Mayevski <vitick_at_gmail.com>
Date: Tue, 7 Dec 2010 22:35:05 -0800

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
>