[ Team LiB ] Previous Section Next Section

The namespace Command

Table 14-1 summarizes the namespace operations:

Table 14-1. The namespace command

namespace current

Returns the current namespace.

namespace children ?name? ?pat?

Returns names of nested namespaces. name defaults to current namespace. pat is a string match pattern that limits what is returned.

namespace code script

Generates a namespace inscope command that will eval script in the current namespace.

namespace delete name ?name? ...

Deletes the variables and commands from the specified namespaces.

namespace eval name cmd ?args? ...

Concatenates args, if present, onto cmd and evaluates it in name namespace.

namespace exists name

Returns 1 if namespace name exists, 0 otherwise. (Tcl 8.4)

namespace export ?-clear? ?pat? ?pat? ...

Adds patterns to the export list for current namespace. Returns export list if no patterns.

namespace forget pat ?pat? ...

Undoes the import of names matching patterns.

namespace import ?-force? pat ?pat? ...

Adds the names matching the patterns to the current namespace.

namespace inscope name cmd ?args? ...

Appends args, if present, onto cmd as list elements and evaluates it in name namespace.

namespace origin cmd

Returns the original name of cmd.

namespace parent ?name?

Returns the parent namespace of name, or of the current namespace.

namespace qualifiers name

Returns the part of name up to the last :: in it.

namespace which ?flag? name

Returns the fully qualified version of name. The flag is one of -command, -variable, or -namespace.

namespace tail name

Returns the last component of name.

    [ Team LiB ] Previous Section Next Section