summaryrefslogtreecommitdiffstats
path: root/doc/namespace.n
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-05-30 00:04:24 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-05-30 00:04:24 (GMT)
commit226baeea03144cecb753db8d1aa9e016d28fac06 (patch)
tree91fac3699c0ef1f44307ec17de71b31609962940 /doc/namespace.n
parente71c1f4ae2af9702d5f0aa3a63f7ef60474ad0be (diff)
downloadtcl-226baeea03144cecb753db8d1aa9e016d28fac06.zip
tcl-226baeea03144cecb753db8d1aa9e016d28fac06.tar.gz
tcl-226baeea03144cecb753db8d1aa9e016d28fac06.tar.bz2
TIP#229 implementation
Diffstat (limited to 'doc/namespace.n')
-rw-r--r--doc/namespace.n36
1 files changed, 31 insertions, 5 deletions
diff --git a/doc/namespace.n b/doc/namespace.n
index 48c570a..60bd8e8 100644
--- a/doc/namespace.n
+++ b/doc/namespace.n
@@ -2,11 +2,12 @@
'\" Copyright (c) 1993-1997 Bell Labs Innovations for Lucent Technologies
'\" Copyright (c) 1997 Sun Microsystems, Inc.
'\" Copyright (c) 2000 Scriptics Corporation.
+'\" Copyright (c) 2004-2005 Donal K. Fellows.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: namespace.n,v 1.17 2005/05/12 16:23:20 dgp Exp $
+'\" RCS: @(#) $Id: namespace.n,v 1.18 2005/05/30 00:04:45 dkf Exp $
'\"
.so man.macros
.TH namespace n 8.5 Tcl "Tcl Built-In Commands"
@@ -216,6 +217,17 @@ for namespace \fInamespace\fR.
If \fInamespace\fR is not specified,
the fully-qualified name of the current namespace's parent is returned.
.TP
+\fBnamespace path\fR ?\fInamespaceList\fR?
+'\" Should really have the .TP inside the .VS, but that triggers a groff bug
+.VS 8.5
+Returns the command resolution path of the current namespace. If
+\fInamespaceList\fR is specified as a list of named namespaces, the
+current namespace's command resolution path is set to those namespaces
+and returns the empty list. The default command resolution path is
+always empty. See the section \fBNAME RESOLUTION\fR below for an
+explanation of the rules regarding name resolution.
+.VE 8.5
+.TP
\fBnamespace qualifiers\fR \fIstring\fR
Returns any leading namespace qualifiers for \fIstring\fR.
Qualifiers are namespace names separated by double colons (\fB::\fR).
@@ -387,10 +399,18 @@ there is no question about what command, variable, or namespace
you mean.
However, if the name does not start with a \fB::\fR
(i.e., is \fIrelative\fR),
-Tcl follows a fixed rule for looking it up:
-Command and variable names are always resolved
+Tcl follows basic rules for looking it up:
+Variable names are always resolved
by looking first in the current namespace,
and then in the global namespace.
+.VS 8.5
+Command names are also always resolved by looking in the current
+namespace first. If not found there, they are searched for in every
+namespace on the current namespace's command path (which is empty by
+default). If not found there, command names are looked up in the
+global namespace (or, failing that, are processed by the \fBunknown\fR
+command.)
+.VE 8.5
Namespace names, on the other hand, are always resolved
by looking in only the current namespace.
.PP
@@ -764,10 +784,16 @@ Create a namespace containing a variable and an exported command:
Call the command defined in the previous example in various ways.
.CS
# Direct call
-foo::grill
+::foo::grill
+
+# Use the command resolution path to find the name
+\fBnamespace eval\fR boo {
+ \fBnamespace path\fR ::foo
+ grill
+}
# Import into current namespace, then call local alias
-namespace import foo::grill
+\fBnamespace import\fR foo::grill
grill
# Create two ensembles, one with the default name and one with a