Uplevel
Encyclopedia
Uplevel is a command in Tcl
Tcl
Tcl is a scripting language created by John Ousterhout. Originally "born out of frustration", according to the author, with programmers devising their own languages intended to be embedded into applications, Tcl gained acceptance on its own...

that allows a command script to be executed in a scope other than the current innermost scope on the stack. Because the command script may itself call procedures that use the uplevel command, this has the net effect of transforming the call stack into a call tree.

It was originally implemented to permit Tcl procedures to reimplement built-in commands (like for, if or while) and still have the ability to manipulate local variables. For example, the following Tcl script is a reimplementation of the for command (omitting exception handling):


proc for {initCmd testExpr advanceCmd bodyScript} {
uplevel 1 $initCmd
set testCmd [list expr $testExpr]
while {[uplevel 1 $testCmd]} {
uplevel 1 $bodyScript
uplevel 1 $advanceCmd
}
}
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK