summaryrefslogtreecommitdiffstats
path: root/doc/upvar.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/upvar.n')
-rw-r--r--doc/upvar.n23
1 files changed, 11 insertions, 12 deletions
diff --git a/doc/upvar.n b/doc/upvar.n
index 145adf9..15fc3b8 100644
--- a/doc/upvar.n
+++ b/doc/upvar.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: upvar.n,v 1.9 2004/11/12 09:01:25 das Exp $
+'\" RCS: @(#) $Id: upvar.n,v 1.10 2004/11/12 11:03:16 dkf Exp $
'\"
.so man.macros
.TH upvar n "" Tcl "Tcl Built-In Commands"
@@ -46,14 +46,14 @@ procedure calling and also makes it easier to build new control constructs
as Tcl procedures.
For example, consider the following procedure:
.CS
-proc \fBadd2\fR name {
+proc \fIadd2\fR name {
\fBupvar\fR $name x
- set x [expr $x+2]
+ set x [expr {$x + 2}]
}
.CE
-\fBadd2\fR is invoked with an argument giving the name of a variable,
-and it adds two to the value of that variable.
-Although \fBadd2\fR could have been implemented using \fBuplevel\fR
+If \fIadd2\fR is invoked with an argument giving the name of a variable,
+it adds two to the value of that variable.
+Although \fIadd2\fR could have been implemented using \fBuplevel\fR
instead of \fBupvar\fR, \fBupvar\fR makes it simpler for \fBadd2\fR
to access the variable in the caller's procedure frame.
.PP
@@ -82,19 +82,18 @@ unexpected manner. If a variable trace is defined on \fIotherVar\fR, that
trace will be triggered by actions involving \fImyVar\fR. However,
the trace procedure will be passed the name of \fImyVar\fR, rather
than the name of \fIotherVar\fR. Thus, the output of the following code
-will be \fBlocalVar\fR rather than \fBoriginalVar\fR:
+will be "\fIlocalVar\fR" rather than "\fIoriginalVar\fR":
.CS
-proc \fBtraceproc\fR { name index op } {
+proc \fItraceproc\fR { name index op } {
puts $name
}
-proc \fBsetByUpvar\fR { name value } {
+proc \fIsetByUpvar\fR { name value } {
\fBupvar\fR $name localVar
set localVar $value
}
set originalVar 1
-trace variable originalVar w \fBtraceproc\fR
-\fBsetByUpvar\fR originalVar 2
-}
+trace variable originalVar w \fItraceproc\fR
+\fIsetByUpvar\fR originalVar 2
.CE
.PP
If \fIotherVar\fR refers to an element of an array, then variable