Nested Namespaces
Namespaces can be nested inside other namespaces. Example 14-3 shows three namespaces that have their own specific variable x. The fully qualified names for these variables are ::foo::x, ::bar::x, and ::bar::foo::x.
Example 14-3 Nested namespaces.
namespace eval foo { variable x 1 ;# ::foo::x } namespace eval bar { variable x 2 ;# ::bar::x namespace foo { variable x 3 ;# ::bar::foo::x } puts $foo::x ;# prints 3 } puts $foo::x ;# prints 1 |
Partially qualified names can refer to two different objects. |
In Example 14-3 the partially qualified name foo::x can reference one of two variables depending on the current namespace. From ...
Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.