Tcl Source Code

Check-in [80b387dbe4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:GOOBE for command results in examples
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 80b387dbe416483fd2ffa2f8462622f8795248c7
User & Date: dkf 2007-10-25 09:58:53.000
Context
2007-10-25
10:02
GOOBE check-in: f8f434410b user: dkf tags: trunk
09:58
GOOBE for command results in examples check-in: 80b387dbe4 user: dkf tags: trunk
09:49
GOOBE applied check-in: 1a9b668373 user: dkf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to doc/upvar.n.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'\"
'\" Copyright (c) 1993 The Regents of the University of California.
'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
'\"
'\" 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.12 2005/05/10 18:34:03 kennykb Exp $
'\" 
.so man.macros
.TH upvar n "" Tcl "Tcl Built-In Commands"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
upvar \- Create link to variable in a different stack frame
.SH SYNOPSIS
\fBupvar \fR?\fIlevel\fR? \fIotherVar myVar \fR?\fIotherVar myVar \fR...?
.BE

.SH DESCRIPTION
.PP
This command arranges for one or more local variables in the current
procedure to refer to variables in an enclosing procedure call or
to global variables.
\fILevel\fR may have any of the forms permitted for the \fBuplevel\fR
command, and may be omitted if the first letter of the first \fIotherVar\fR







|










<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

19
20
21
22
23
24
25
'\"
'\" Copyright (c) 1993 The Regents of the University of California.
'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
'\"
'\" 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.13 2007/10/25 09:58:53 dkf Exp $
'\" 
.so man.macros
.TH upvar n "" Tcl "Tcl Built-In Commands"
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
.SH NAME
upvar \- Create link to variable in a different stack frame
.SH SYNOPSIS
\fBupvar \fR?\fIlevel\fR? \fIotherVar myVar \fR?\fIotherVar myVar \fR...?
.BE

.SH DESCRIPTION
.PP
This command arranges for one or more local variables in the current
procedure to refer to variables in an enclosing procedure call or
to global variables.
\fILevel\fR may have any of the forms permitted for the \fBuplevel\fR
command, and may be omitted if the first letter of the first \fIotherVar\fR
77
78
79
80
81
82
83



84
85
86
87
88
89
90
91
.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 "\fIlocalVar\fR" rather than "\fIoriginalVar\fR":
.CS
proc \fItraceproc\fR { name index op } {
   puts $name
}
proc \fIsetByUpvar\fR { name value } {
   \fBupvar\fR $name localVar
   set localVar $value







>
>
>
|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
.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
.QW "\fIlocalVar\fR"
rather than
.QW "\fIoriginalVar\fR" :
.CS
proc \fItraceproc\fR { name index op } {
   puts $name
}
proc \fIsetByUpvar\fR { name value } {
   \fBupvar\fR $name localVar
   set localVar $value
105
106
107
108
109
110
111
112
113
114
115
116
117
the value from the variable instead of adding it:
.CS
proc decr {varName {decrement 1}} {
    \fBupvar\fR 1 $varName var
    incr var [expr {-$decrement}]
}
.CE

.SH "SEE ALSO"
global(n), namespace(n), uplevel(n), variable(n)

.SH KEYWORDS
context, frame, global, level, namespace, procedure, variable







<


<


107
108
109
110
111
112
113

114
115

116
117
the value from the variable instead of adding it:
.CS
proc decr {varName {decrement 1}} {
    \fBupvar\fR 1 $varName var
    incr var [expr {-$decrement}]
}
.CE

.SH "SEE ALSO"
global(n), namespace(n), uplevel(n), variable(n)

.SH KEYWORDS
context, frame, global, level, namespace, procedure, variable