namespace
namespace subcommand ?arg ...?
The commands for namespaces: groups of commands and variables with a name. :: is the top namespace, and a::b is a namespace in a.
Subcommands
| Synopsis | What it does |
|---|---|
namespace eval NS SCRIPT |
Runs SCRIPT in NS, and makes NS when it does not exist. |
namespace current |
The name of the current namespace. |
namespace children ?NS? ?PATTERN? |
The namespaces in NS. |
namespace parent ?NS? |
The namespace around NS. |
namespace exists NS |
1 when NS exists. |
namespace delete ?NS ...? |
Removes namespaces with their commands and variables. |
namespace export ?-clear? ?PATTERN ...? |
The commands that other code can import, and that an ensemble has. |
namespace import ?-force? ?PATTERN ...? |
Makes the exported commands of another namespace callable by their short names. |
namespace forget ?PATTERN ...? |
Removes imported commands. |
namespace ensemble create ?-option value ...? |
Makes the namespace a command with its exported commands as subcommands. configure and exists go with it. |
namespace path ?LIST? |
The namespaces where a command name is looked up after the current one. |
namespace which ?-command? ?-variable? NAME |
The full name of a command or variable, or an empty string. |
namespace origin CMD |
The full name of the command that an imported command points to. |
namespace qualifiers NAME |
The part of NAME before its last ::. |
namespace tail NAME |
The part of NAME after its last ::. |
namespace code SCRIPT |
A script that runs in the current namespace from each place, for a callback. |
namespace inscope NS SCRIPT ?ARG ...? |
Runs SCRIPT in NS. namespace code makes this form. |
namespace upvar NS OTHERVAR MYVAR ?OTHERVAR MYVAR ...? |
Links local names to variables of NS. |
namespace unknown ?SCRIPT? |
The handler of an unknown command in the namespace. |
Examples
A click on an example runs it in the shell of the page.
namespace eval jot {proc add {} {return added}; namespace export add; namespace ensemble create}; jot add:addednamespace tail ::a::b::c:cnamespace qualifiers ::a::b::c:::a::b
Facts
- Capability: none.
- Compute cost: one compute unit for the call, and more for the commands that it runs.