Manual Pages for UNIX Darwin command on man uplevel
MyWebUniversity

Manual Pages for UNIX Darwin command on man uplevel

uplevel(n) Tcl Built-In Commands uplevel(n)

NAME

uplevel - Execute a script in a different stack frame

SYNOPSIS

uupplleevveell ?level? arg ?arg ...?

DESCRIPTION

All of the arg arguments are concatenated as if they had been passed to ccoonnccaatt; the result is then evaluated in the variable context indicated by level. UUpplleevveell returns the result of that evaluation.

If level is an integer then it gives a distance (up the procedure call-

ing stack) to move before executing the command. If level consists of

## followed by a number then the number gives an absolute level number.

If level is omitted then it defaults to 11. Level cannot be defaulted

if the first command argument starts with a digit or ##.

For example, suppose that procedure aa was invoked from top-level, and

that it called bb, and that bb called cc. Suppose that cc invokes the

uupplleevveell command. If level is 11 or ##22 or omitted, then the command

will be executed in the variable context of bb. If level is 22 or ##11

then the command will be executed in the variable context of aa. If

level is 33 or ##00 then the command will be executed at top-level (only

global variables will be visible). The uupplleevveell command causes the invoking procedure to disappear from the procedure calling stack while the command is being executed. In the above example, suppose cc invokes the command uupplleevveell 11 {{sseett xx 4433;; dd}} where dd is another Tcl procedure. The sseett command will modify the variable xx in bb's context, and dd will execute at level 3, as if called from bb. If it in turn executes the command uupplleevveell {{sseett xx 4422}} then the sseett command will modify the same variable xx in bb's context:

the procedure cc does not appear to be on the call stack when dd is exe-

cuting. The command ``iinnffoo lleevveell'' may be used to obtain the level of the current procedure. UUpplleevveell makes it possible to implement new control constructs as Tcl procedures (for example, uupplleevveell could be used to implement the wwhhiillee construct as a Tcl procedure). nnaammeessppaaccee eevvaall is another way (besides procedure calls) that the Tcl

naming context can change. It adds a call frame to the stack to repre-

sent the namespace context. This means each nnaammeessppaaccee eevvaall command

counts as another call level for uupplleevveell and uuppvvaarr commands. For exam-

ple, iinnffoo lleevveell 11 will return a list describing a command that is either the outermost procedure call or the outermost nnaammeessppaaccee eevvaall

command. Also, uupplleevveell ##00 evaluates a script at top-level in the out-

ermost namespace (the global namespace).

SEE ALSO

namespace(n), upvar(n) KKEEYYWWOORRDDSS context, level, namespace, stack frame, variables

Tcl uplevel(n)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™