TIP #139 Version 1.1: Publish Part of Tcl's Namespace API

This is not necessarily the current version of this TIP.


TIP:139
Title:Publish Part of Tcl's Namespace API
Version:$Revision: 1.1 $
Author:Donal K. Fellows <donal dot k dot fellows at man dot ac dot uk>
State:Draft
Type:Project
Tcl-Version:8.5
Vote:Pending
Created:Tuesday, 03 June 2003

Abstract

This TIP makes the simpler parts of Tcl's Namespace API available to the general C-coding public.

Rationale

Tcl has had namespace support for a number of years now, ever since version 8.0. However, the C API for working with namespaces (as opposed to the script-level [namespace] command) has been hidden inside Tcl's private header files for all that time. This is mainly because of the complexity of some of the interfaces; name resolution is definitely difficult to document.

But about half the API is not so encumbered, being the parts that deal with basic features like creation and destruction of namespaces themselves. It is these simpler parts that this TIP exposes as they have little risk of changing in the future, and I believe they should be made public particularly as it would allow extensions that create commands in namespaces to ensure the existence of the namespace first without resorting to applying Tcl_Eval to a small script.

This TIP does not call for any alteration to the name, signature or behaviour of any API function at all. Note that these functions already have "public" names.

Exposed API Functions

There are the following new public functions:

Tcl_CreateNamespace

Creates a new namespace.

Tcl_DeleteNamespace

Deletes an existing namespace.

Tcl_AppendExportList

Retrieves the export patterns for a namespace.

Tcl_Export

Set/append to the export patterns for a namespace.

Tcl_Import

Import commands matching a pattern into a namespace.

Tcl_ForgetImport

Remove imports matching a pattern.

Tcl_GetCurrentNamespace

Retrieve the current namespace.

Tcl_GetGlobalNamespace

Retrieve the global namespace.

Tcl_FindNamespace

Search for a namespace.

Tcl_FindCommand

Search for a command and return its token, optionally in a namespace. Note that command tokens are already returned from Tcl_CreateCommand and Tcl_CreateObjCommand so this is not a new type of result.

Tcl_GetCommandFromObj

Get a command token given a name.

Tcl_GetCommandFullName

Get the full name of a command from its token.

Each of these functions will be declared in future within tcl.decls (with the entries in tclInt.decls deprecated) and will also be documented.

Copyright

This document is placed in the public domain.


Powered by TclThis is not necessarily the current version of this TIP.

TIP AutoGenerator - written by Donal K. Fellows