From 0d01ef9eb8b4f1e51b3b2401f02f0b7aa6c92ecc Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 27 Dec 2009 22:09:18 +0000 Subject: [Bug 2921538]: Updated example to not be quite so ancient. --- ChangeLog | 5 +++++ doc/namespace.n | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2601382..7e4fcd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-27 Donal K. Fellows + + * doc/namespace.n (SCOPED SCRIPTS): [Bug 2921538]: Updated example to + not be quite so ancient. + 2009-12-23 Donal K. Fellows * library/safe.tcl (AliasSource, AliasExeName): [Bug 2913625]: Stop 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 -- cgit v0.12