diff options
author | phk <phk@FreeBSD.org> | 1996-06-26 06:06:43 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1996-06-26 06:06:43 +0000 |
commit | 00febf60093a024ccc629fdfc81e02a40c5f6572 (patch) | |
tree | 4d70f77f44120e6541d1418223baf06562774975 /contrib/tcl/doc/uplevel.n | |
download | FreeBSD-src-00febf60093a024ccc629fdfc81e02a40c5f6572.zip FreeBSD-src-00febf60093a024ccc629fdfc81e02a40c5f6572.tar.gz |
Tcl 7.5, various makefiles will be updated to use these sources as soon
as I get these back down to my machine.
Diffstat (limited to 'contrib/tcl/doc/uplevel.n')
-rw-r--r-- | contrib/tcl/doc/uplevel.n | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/contrib/tcl/doc/uplevel.n b/contrib/tcl/doc/uplevel.n new file mode 100644 index 0000000..574900e --- /dev/null +++ b/contrib/tcl/doc/uplevel.n @@ -0,0 +1,66 @@ +'\" +'\" Copyright (c) 1993 The Regents of the University of California. +'\" Copyright (c) 1994-1996 Sun Microsystems, Inc. +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +'\" SCCS: @(#) uplevel.n 1.7 96/03/25 20:26:46 +'\" +.so man.macros +.TH uplevel n "" Tcl "Tcl Built-In Commands" +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +uplevel \- Execute a script in a different stack frame +.SH SYNOPSIS +\fBuplevel \fR?\fIlevel\fR?\fI arg \fR?\fIarg ...\fR? +.BE + +.SH DESCRIPTION +.PP +All of the \fIarg\fR arguments are concatenated as if they had +been passed to \fBconcat\fR; the result is then evaluated in the +variable context indicated by \fIlevel\fR. \fBUplevel\fR returns +the result of that evaluation. +.PP +If \fIlevel\fR is an integer then +it gives a distance (up the procedure calling stack) to move before +executing the command. If \fIlevel\fR consists of \fB#\fR followed by +a number then the number gives an absolute level number. If \fIlevel\fR +is omitted then it defaults to \fB1\fR. \fILevel\fR cannot be +defaulted if the first \fIcommand\fR argument starts with a digit or \fB#\fR. +.PP +For example, suppose that procedure \fBa\fR was invoked +from top-level, and that it called \fBb\fR, and that \fBb\fR called \fBc\fR. +Suppose that \fBc\fR invokes the \fBuplevel\fR command. If \fIlevel\fR +is \fB1\fR or \fB#2\fR or omitted, then the command will be executed +in the variable context of \fBb\fR. If \fIlevel\fR is \fB2\fR or \fB#1\fR +then the command will be executed in the variable context of \fBa\fR. +If \fIlevel\fR is \fB3\fR or \fB#0\fR then the command will be executed +at top-level (only global variables will be visible). +.PP +The \fBuplevel\fR command causes the invoking procedure to disappear +from the procedure calling stack while the command is being executed. +In the above example, suppose \fBc\fR invokes the command +.CS +\fBuplevel 1 {set x 43; d}\fR +.CE +where \fBd\fR is another Tcl procedure. The \fBset\fR command will +modify the variable \fBx\fR in \fBb\fR's context, and \fBd\fR will execute +at level 3, as if called from \fBb\fR. If it in turn executes +the command +.CS +\fBuplevel {set x 42}\fR +.CE +then the \fBset\fR command will modify the same variable \fBx\fR in \fBb\fR's +context: the procedure \fBc\fR does not appear to be on the call stack +when \fBd\fR is executing. The command ``\fBinfo level\fR'' may +be used to obtain the level of the current procedure. +.PP +\fBUplevel\fR makes it possible to implement new control +constructs as Tcl procedures (for example, \fBuplevel\fR could +be used to implement the \fBwhile\fR construct as a Tcl procedure). + +.SH KEYWORDS +context, stack frame, variables |