uplevel
개요 : Execute a script in a different stack frame
Syntax : uplevel ?level? arg ?arg ...?
Process
1. All of the arg arguments are concatenated
2. The concatenated result is evaluated in the variable context indicated
by level.
3. Returns the result of that evaluation.
If level is omitted then it defaults to 1
info level 명령어
level of the current procedure 반환
예시
상황 : Procedure a was invoked from top-level, a called b, and b called c.
top level - a - b - c 순서대로 각각 level #0 - #1 - #2 - #3
Suppose that c invokes the uplevel command.
If level is 1 or #2 or omitted, then the command will be executed in the
variable context of b.
If level is 2 or #1 then the command will be executed in the variable
context of a.
If level is 3 or #0 then the command will be executed at top-level (only
global variables will be visible).
c 가 다음 명령어 uplevel 1 {set x 43; d} 을 호출했다고 가정. d is another
Tcl procedure
The set x 43 은 b's context에서 수행되고, d는 level #3 에서 수행됨.
연이어 uplevel {arg} 수행 시, 여전히 b's context에서 arg 수행.