diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-19 11:04:59 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-19 11:04:59 (GMT) |
commit | afa9e11fbb2ed6004416f10b8910e0ac6d80da37 (patch) | |
tree | a9cfb4dbb99f3ef4377794a9b2d016c44c5efe88 /doc | |
parent | 072812c72513ce97b98cfde33cdecb9ef061d58a (diff) | |
parent | b1d37d0ae95ead265ed709c6f9325651e237b596 (diff) | |
download | tcl-afa9e11fbb2ed6004416f10b8910e0ac6d80da37.zip tcl-afa9e11fbb2ed6004416f10b8910e0ac6d80da37.tar.gz tcl-afa9e11fbb2ed6004416f10b8910e0ac6d80da37.tar.bz2 |
Fix [53ac20f94b]: namespace(n) documentation doesn't reflect TIP#278 changes
Diffstat (limited to 'doc')
-rw-r--r-- | doc/namespace.n | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/doc/namespace.n b/doc/namespace.n index 5f02082..c19791c 100644 --- a/doc/namespace.n +++ b/doc/namespace.n @@ -495,8 +495,10 @@ However, if the name does not start with a \fB::\fR (i.e., is \fIrelative\fR), Tcl follows basic rules for looking it up: .IP \(bu -\fBVariable names\fR are always resolved by looking first in the current -namespace, and then in the global namespace. +\fBVariable names\fR are always resolved starting in the current +namespace. In the absence of special resolvers, foo::bar::baz refers to +a variable named "baz" in a namespace named "bar" that is a child of a +namespace named "foo" that is a child of the current namespace of the interpreter. .IP \(bu \fBCommand names\fR are always resolved by looking in the current namespace first. If not found there, they are searched for in every namespace on the @@ -516,10 +518,9 @@ set traceLevel 0 } .CE .PP -Tcl looks for \fBtraceLevel\fR in the namespace \fBDebug\fR -and then in the global namespace. +Tcl looks for \fBtraceLevel\fR in the namespace \fBDebug\fR. It looks up the command \fBprintTrace\fR in the same way. -If a variable or command name is not found in either context, +If a variable or command name is not found, the name is undefined. To make this point absolutely clear, consider the following example: .PP @@ -534,11 +535,9 @@ set traceLevel 0 } .CE .PP -Here Tcl looks for \fBtraceLevel\fR first in the namespace \fBFoo::Debug\fR. -Since it is not found there, Tcl then looks for it -in the global namespace. -The variable \fBFoo::traceLevel\fR is completely ignored -during the name resolution process. +Here Tcl looks for \fBtraceLevel\fR in the namespace \fBFoo::Debug\fR. +The variables \fBFoo::traceLevel\fR and \fBFoo::Debug::traceLevel\fR +are completely ignored during the name resolution process. .PP You can use the \fBnamespace which\fR command to clear up any question about name resolution. @@ -548,19 +547,19 @@ For example, the command: \fBnamespace eval\fR Foo::Debug {\fBnamespace which\fR -variable traceLevel} .CE .PP -returns \fB::traceLevel\fR. -On the other hand, the command, +returns the empty string. +The command, .PP .CS \fBnamespace eval\fR Foo {\fBnamespace which\fR -variable traceLevel} .CE .PP -returns \fB::Foo::traceLevel\fR. +returns the empty string as well. .PP As mentioned above, -namespace names are looked up differently -than the names of variables and commands. -Namespace names are always resolved in the current namespace. +namespace names and variables are looked up differently +than the names of commands. +Namespace names and variables are always resolved in the current namespace. This means, for example, that a \fBnamespace eval\fR command that creates a new namespace always creates a child of the current namespace |