10. Namespaces

The Tcl interpreter collects all commands and global variables into groups called namespaces, so that commands and variables within one namespace don’t interfere with commands in another. These namespaces themselves are arranged in a tree, and commands in one namespace can be imported into another. The root of the tree is the global namespace, and it contains all commands and variables that are not created explicitly within some other namespace.

Commands and variables may be created within or used from out of any existing namespace. This is done by prefixing the name of the namespace to the command or variable name, separated by the namespace separator, a double colon. The name of the global namespace is an empty string, but a ...

Get Tcl and the Tk Toolkit, Second 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.