This is not necessarily the current version of this TIP.
| TIP: | 229 |
| Title: | Scripted Control of Name Resolution in Namespaces |
| 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: | Wednesday, 03 November 2004 |
This TIP proposes extensions to the namespace command to allow scripts to control how individual namespaces map names to commands and variables.
Tcl has, for historic reasons, attracted many different styles of object system, and a favoured mechanism for implementing objects is on top of namespaces (which were introduced in Tcl 8.0 based on work done previously in [incr Tcl]). However, a common problem that these OO systems face is the inability to make namespaces efficiently map names of entities within classes etc. into the object instances. This TIP provides a simple mechanism for doing this.
The namespace command will gain a new subcommand, path, with the following syntax:
namespace path type ?-append/-prepend? ?list?
The type argument specifies which name resolution path will be manipulated. Two types will be supported: command (which describes how commands in the namespace are looked up) and variable (which does the same for variables).
If the list argument is missing, the result of the command will be the current path for the given type. No update will be performed. Neither option argument will be allowed.
If the list argument is present, it will be a list of namespaces to search when looking up an a named entity of the given type. The current namespace will always be searched first. By default, the path will be set, but if the -prepend option is passed, the given list of namespaces will be inserted at the front of the path, and similarly if the -append option is passed, the list will be appended to the path. The result of the command will be the resulting path.
The default path for both commands and variables will be "::" (the root namespace) only.
This document has been placed in the public domain.
This is not necessarily the current version of this TIP.