diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2009-12-27 22:09:18 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2009-12-27 22:09:18 (GMT) |
commit | 0d01ef9eb8b4f1e51b3b2401f02f0b7aa6c92ecc (patch) | |
tree | ad091fe829757c3b66856b047fbe9d64611ead47 /doc/namespace.n | |
parent | 536c877f97457bb6e3f4b05ba69f28df96caec8c (diff) | |
download | tcl-0d01ef9eb8b4f1e51b3b2401f02f0b7aa6c92ecc.zip tcl-0d01ef9eb8b4f1e51b3b2401f02f0b7aa6c92ecc.tar.gz tcl-0d01ef9eb8b4f1e51b3b2401f02f0b7aa6c92ecc.tar.bz2 |
[Bug 2921538]: Updated example to not be quite so ancient.
Diffstat (limited to 'doc/namespace.n')
-rw-r--r-- | doc/namespace.n | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/doc/namespace.n b/doc/namespace.n index f2be10d..8f7ba00 100644 --- a/doc/namespace.n +++ b/doc/namespace.n @@ -7,7 +7,7 @@ '\" 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.30.2.1 2008/09/07 14:01:10 msofer Exp $ +'\" RCS: @(#) $Id: namespace.n,v 1.30.2.2 2009/12/27 22:09:18 dkf Exp $ '\" .so man.macros .TH namespace n 8.5 Tcl "Tcl Built-In Commands" @@ -632,12 +632,14 @@ may be imported by other namespaces. If a \fBnamespace import\fR command specifies a command that is not exported, the command is not imported. .SH "SCOPED SCRIPTS" +.PP The \fBnamespace code\fR command is the means by which a script may be packaged for evaluation in a namespace other than the one in which it was created. It is used most often to create event handlers, Tk bindings, and traces for evaluation in the global context. For instance, the following -code indicates how to direct a variable trace callback into the current +code indicates how to direct a variable \fBtrace\fR callback into the current namespace: +.PP .CS \fBnamespace eval\fR a { variable b @@ -646,11 +648,13 @@ namespace: puts "the value of $n1 has changed to $var" return } - trace variable b w [\fBnamespace code\fR theTraceCallback] + trace add variable b write [\fBnamespace code\fR theTraceCallback] } set a::b c .CE +.PP When executed, it prints the message: +.PP .CS the value of a::b has changed to c .CE |