namespace which

Synopsis

namespace which ?-command? ?-variable? name

Description

Returns the fully-qualified name of a routine named name if it exists, and the empty string otherwise. Searches for a variable instead if -variable is provided. The search is performed as described in section NAME RESOLUTION: The current namespace is searched, followed by any namespace in the path of the current namespace, and finally by the global namespace. A variable that has been created but not defined, e.g. with variable, trace, is considered to exist.

There is currently no option to prevent namespace which from searching in the global namespace.

namespace which not recognize variables in an array, but it does recognize an array variable itself.

namespace which for array elements

2010-06-09 HaO:

For me, it was surprising that

[namespace which -variable array(element)]

returns the empty string, even if

info exists array(element)

returns true (e.g. the array element exists).

One might use for array elements:

[namespace which -variable array](element)

which works but is IMHO nor beautiful, robust or optimizeable by the byte code compiler.

MS points to TCL Ticket 472113