diff options
author | ericm <ericm@noemail.net> | 2000-01-21 03:29:12 (GMT) |
---|---|---|
committer | ericm <ericm@noemail.net> | 2000-01-21 03:29:12 (GMT) |
commit | 7ddf5074dfd0d363a565036a5f7fcf64ac173497 (patch) | |
tree | a768d15a2696f9c09dbf4f2cee292c1b142f1363 /doc | |
parent | 2fbc5c9d6042eff1c1d43b055695dabdee98393b (diff) | |
download | tcl-7ddf5074dfd0d363a565036a5f7fcf64ac173497.zip tcl-7ddf5074dfd0d363a565036a5f7fcf64ac173497.tar.gz tcl-7ddf5074dfd0d363a565036a5f7fcf64ac173497.tar.bz2 |
* var.test: Added tests for corrected variable behavior (bug #981).
* upvar.n: Expanded explanation of upvar behavior with respect to
variable traces. (bugs 3917 1433 2110).
* tclVar.c: Changed behavior of variable command when name refers
to an element in an array (ie, "variable foo(x)") to always return
an error, regardless of existance of that element in the array
(now behavior is consistant with docs too) (bug #981).
FossilOrigin-Name: 4521696b9889a95617c9e09d9b76d94efa5bd049
Diffstat (limited to 'doc')
-rw-r--r-- | doc/upvar.n | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/doc/upvar.n b/doc/upvar.n index f62d646..3f6792c 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.2 1998/09/14 18:39:56 stanton Exp $ +'\" RCS: @(#) $Id: upvar.n,v 1.3 2000/01/21 03:29:13 ericm Exp $ '\" .so man.macros .TH upvar n "" Tcl "Tcl Built-In Commands" @@ -76,8 +76,28 @@ 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 BUGS +.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 +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: +.CS +\fBproc traceproc { name index op } { + puts $name +} +proc setByUpvar { name value } { + upvar $name localVar + set localVar $value +} +set originalVar 1 +trace variable originalVar w traceproc +setByUpvar originalVar 2 +}\fR +.CE + If \fIotherVar\fR refers to an element of an array, then variable traces set for the entire array will not be invoked when \fImyVar\fR is accessed (but traces on the particular element will still be |