summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-05-18 21:29:22 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-05-18 21:29:22 (GMT)
commit46487a4cd235093ea1a14c1426132ac0f291428a (patch)
tree38ebef35c4701513506becd301798fa67d6d4073
parent8f44551e03712b6046cecdfc9e8ce0ba1b4a5225 (diff)
downloadtcl-46487a4cd235093ea1a14c1426132ac0f291428a.zip
tcl-46487a4cd235093ea1a14c1426132ac0f291428a.tar.gz
tcl-46487a4cd235093ea1a14c1426132ac0f291428a.tar.bz2
Added example
-rw-r--r--ChangeLog2
-rw-r--r--doc/upvar.n14
2 files changed, 12 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 16b24f3..2e6e26f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
2004-05-18 Donal K. Fellows <donal.k.fellows@man.ac.uk>
- * doc/append.n: Added example.
+ * doc/append.n, doc/upvar.n: Added example.
2004-05-18 David Gravereaux <davygrvy@pobox.com>
diff --git a/doc/upvar.n b/doc/upvar.n
index 84399c7..bb25fee 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.6 2004/04/28 13:11:33 msofer Exp $
+'\" RCS: @(#) $Id: upvar.n,v 1.7 2004/05/18 21:29:22 dkf Exp $
'\"
.so man.macros
.TH upvar n "" Tcl "Tcl Built-In Commands"
@@ -75,8 +75,7 @@ upvar variable. There is no way to unset an upvar variable except
by exiting the procedure in which it is defined. However, it is
possible to retarget an upvar variable by executing another \fBupvar\fR
command.
-
-.SH Traces and upvar
+.SH "TRACES AND UPVAR"
.PP
Upvar interacts with traces in a straightforward but possibly
unexpected manner. If a variable trace is defined on \fIotherVar\fR, that
@@ -104,6 +103,15 @@ is accessed (but traces on the particular element will still be
invoked). In particular, if the array is \fBenv\fR, then changes
made to \fImyVar\fR will not be passed to subprocesses correctly.
.VE
+.SH EXAMPLE
+A \fBdecr\fR command that works like \fBincr\fR except it subtracts
+the value from the variable instead of adding it:
+.CS
+proc decr {varName {decrement 1}} {
+ upvar 1 $varName var
+ incr var [expr {-$decrement}]
+}
+.CE
.SH "SEE ALSO"
global(n), namespace(n), uplevel(n), variable(n)