Tcl_AppendExportList, Tcl_CreateNamespace, Tcl_DeleteNamespace, Tcl_Export, Tcl_FindCommand, Tcl_FindNamespace, Tcl_ForgetImport, Tcl_GetCurrentNamespace, Tcl_GetGlobalNamespace, Tcl_GetNamespaceUnknownHandler, Tcl_Import, Tcl_SetNamespaceUnknownHandler − manipulate namespaces


#include <tcl.h>

Tcl_Namespace *
(interp, name, clientData, deleteProc)


(interp, nsPtr, objPtr)

(interp, nsPtr, pattern, resetListFirst)

(interp, nsPtr, pattern, allowOverwrite)

(interp, nsPtr, pattern)

Tcl_Namespace *

Tcl_Namespace *

Tcl_Namespace *
(interp, name, contextNsPtr, flags)

(interp, name, contextNsPtr, flags)

Tcl_Obj *
interp, nsPtr)

interp, nsPtr, handlerPtr)


Tcl_Interp *interp (in/out)

The interpreter in which the namespace exists and where name lookups are performed. Also where error result messages are written.

const char *name (in)

The name of the namespace or command to be created or accessed.

ClientData clientData (in)

A context pointer by the creator of the namespace. Not interpreted by Tcl at all.

Tcl_NamespaceDeleteProc *deleteProc (in)

A pointer to function to call when the namespace is deleted, or NULL if no such callback is to be performed.

Tcl_Namespace *nsPtr (in)

The namespace to be manipulated, or NULL (for other than Tcl_DeleteNamespace) to manipulate the current namespace.

Tcl_Obj *objPtr (out)

A reference to an unshared object to which the function output will be written.

const char *pattern (in)

The glob-style pattern (see Tcl_StringMatch) that describes the commands to be imported or exported.

int resetListFirst (in)

Whether the list of export patterns should be reset before adding the current pattern to it.

int allowOverwrite (in)

Whether new commands created by this import action can overwrite existing commands.

Tcl_Namespace *contextNsPtr (in)

The location in the namespace hierarchy where the search for a namespace or command should be conducted relative to when the search term is not rooted at the global namespace. NULL indicates the current namespace.

int flags (in)

OR-ed combination of bits controlling how the search is to be performed. The following flags are supported: TCL_GLOBAL_ONLY (indicates that the search is always to be conducted relative to the global namespace), TCL_NAMESPACE_ONLY (just for Tcl_FindCommand; indicates that the search is always to be conducted relative to the context namespace), and TCL_LEAVE_ERR_MSG (indicates that an error message should be left in the interpreter if the search fails.)

Tcl_Obj *handlerPtr (in)

A script fragment to be installed as the unknown command handler for the namespace, or NULL to reset the handler to its default.



Namespaces are hierarchic naming contexts that can contain commands and variables. They also maintain a list of patterns that describes what commands are exported, and can import commands that have been exported by other namespaces. Namespaces can also be manipulated through the Tcl command namespace.

The Tcl_Namespace structure encapsulates a namespace, and is guaranteed to have the following fields in it: name (the local name of the namespace, with no namespace separator characters in it, with empty denoting the global namespace), fullName (the fully specified name of the namespace), clientData, deleteProc (the values specified in the call to Tcl_CreateNamespace), and parentPtr (a pointer to the containing namespace, or NULL for the global namespace.)

Tcl_CreateNamespace creates a new namespace. The deleteProc will have the following type signature:

typedef void (Tcl_NamespaceDeleteProc) (ClientData clientData);

Tcl_DeleteNamespace deletes a namespace.

Tcl_AppendExportList retrieves the export patterns for a namespace given namespace and appends them (as list items) to objPtr.

Tcl_Export sets and appends to the export patterns for a namespace. Patterns are appended unless the resetListFirst flag is true.

Tcl_Import imports commands matching a pattern into a namespace. Note that the pattern must include the name of the namespace to import from. This function returns an error if an attempt to import a command over an existing command is made, unless the allowOverwrite flag has been set.

Tcl_ForgetImport removes imports matching a pattern.

Tcl_GetCurrentNamespace returns the current namespace for an interpreter.

Tcl_GetGlobalNamespace returns the global namespace for an interpreter.

Tcl_FindNamespace searches for a namespace named name within the context of the namespace contextNsPtr. If the namespace cannot be found, NULL is returned.

Tcl_FindCommand searches for a command named name within the context of the namespace contextNsPtr. If the command cannot be found, NULL is returned.

Tcl_GetNamespaceUnknownHandler returns the unknown command handler for the namespace, or NULL if none is set.

Tcl_SetNamespaceUnknownHandler sets the unknown command handler for the namespace. If handlerPtr is NULL, then the handler is reset to its default.


Tcl_CreateCommand, Tcl_ListObjAppendElements, Tcl_SetVar


namespace, command

More Linux Commands

cachemgr.cgi(8) - squid HTTP proxy manager interface........
The cache manager (cachemgr.cgi) is a CGI utility for displaying statistics about the Squid HTTP proxy process as it runs. The cache manager is a convenient way

dot(1) - filter for drawing directed graphs - Linux man page
These are a collection of programs for drawing graphs. There is actually only one main program; the specific layout algorithms implemented as plugins. Thus, the

menu_format(3menu) - set and get menu sizes - Linux man page
menu_format.3menu - The function set_menu_format sets the maximum display size of the given menu. If this size is too small to display all menu items, the menu

ldap_sort_values(3) - LDAP sorting routines (deprecated)....
The ldap_sort_entries(), ldap_sort_values(), and ldap_sort_strcasecmp() are deprecated. Deprecated interfaces generally remain in the library. The macro LDAP_DE

plainrsa-gen(8) - generator for Plain RSA keys (Man Page)...
plainrsa-gen can be used to generate Plain RSA keys for authentication purposes. Using Plain RSA keys is optional. Other possibilities are Pre-shared keys or X.

XF86VidModeGetPermissions(3) - Extension library for the XFr
These functions provide an interface to the server extension XFree86-VidModeExtension which allows the video modes to be queried and adjusted dynamically and mo

TAP::Parser::Result::Unknown(3pm) - Unknown result token....
This is a subclass of TAP::Parser::Result. A token of this class will be returned if the parser does not recognize the token line. For example: 1..5 VERSION 7 o

putchar_unlocked(3) - nonlocking stdio functions (Man Page)
Each of these functions has the same behavior as its counterpart without the _unlocked suffix, except that they do not use locking (they do not set locks themse

reader.conf(5) configuration file for pcscd readers drivers
The /etc/reader.conf.d/reader.conf file contains configuration information for serial and (some) PCMCIA smart card readers. USB readers SHALL NOT be configured

Tcl_GetMathFuncInfo(3) - Define, query and enumerate math fu
Tcl allows a number of mathematical functions to be used in expressions, such as sin, cos, and hypot. These functions are represented by commands in the namespa

cvs(1) - Concurrent Versions System - Linux manual page.....
connection (see node GSSAPI authenticated in the CVS manual) or a Kerberos connection (see node Kerberos authenticated in the CVS manual). Enabling encryption i

lvresize(8) - resize a logical volume - Linux manual page...
lvresize allows you to resize a logical volume. Be careful when reducing a logical volumes size, because data in the reduced part is lost!!! You should therefor

We can't live, work or learn in freedom unless the software we use is free.