Version 5 of namespace path

Updated 2009-11-02 12:04:27 by wdb

wdb This command shows or extends the namespace where an input command is searched in.

In this example, the namespace is extended:

% namespace path "tcl::mathfunc tcl::mathop"
% 

Now, you can input math-related commands as follows:

% hypot 3 [+ 2 2]
5.0
% 

In this example, the namespace extension is shown.

% namespace path
::tcl::mathfunc ::tcl::mathop
% 

Note that the namespaces argument is one proper list. It is not possible to input namespaces as single arguments. (Is it a matter of discussion if that should be possible?)

Note that namespace path can be executed differently in different namespaces.

(DKF: What does this paragraph mean? Please clarify.)

wdb In namespace test there can exist a path different from path in :: -- example:

% namespace eval test namespace path ::tcl::mathop
%

inside newly created namespace test, path is extended to ::tcl::mathop. Now, check it out:

% namespace eval test namespace path
::tcl::mathop
%

Indeed, path is extended. Now check it in namespace ::

% namespace path
%

In namespace ::, obviously there is no path extension. Check if ::tcl::mathop::+ is known in namespace test:

% namespace eval test + 5 6
11
%

Check the samein namespace :: leads to failure:

% + 5 6
invalid command name "+"
%