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

Re: [Xotcl] Possible bug in NX

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Wed, 16 Mar 2011 06:29:58 +0100

Dear Victor,

i don't think, nx/xotcl should brace a scalar return values.
Look at plain Tcl:
Tcl does not brace a string with a space either:

% set x "a b"
a b

For what reason should nx/xotcl do it? There are many other
commands in nx, doing the same, such as e.g. "create"

% nx::Object create "a b"
::a b
% nx::Object create "a b::c d"
::a b::c d
% nx::Object create "a b::e"
::a b::e

... and therefore "info parent" has no reason to add braces:

% "a b::c d" info parent
::a b

In situations, where a list is returned (potentially
multiple elements) the elements have to be are proper list
elements and therefore these elements are escaped, even if
the result is a list with a single element:

% "a b" info children
{::a b::e} {::a b::c d}

This is the same in plain Tcl as well: "info commands"
returns a list of elements:

% info commands "::a *"
{::a b}
% info commands "::a b::*"
{::a b::e} {::a b::c d}

again, the command as a scalar:

% lindex [info commands "::a b::*"] 0
::a b::e
%

So, the rule is: list are properly escaped, scalars are the
plain values.

all the best
-gustaf

On 16.03.11 01:48, Victor Mayevski wrote:
> Hello Gustaf,
>
> I encountered an issue with [info parent] and where parent's name
> contains a space. While [info children] behaves correctly by returning
> a list:
> {::pa rent::child}
> [info parent] just returns the name:
> ::pa rent
> instead of:
> {::pa rent}
> This is fixable by using [list [info parent]] but I wonder if that
> should be the default behavior in NX anyway?
>
> Thanks,
>
> Victor