info level
Gives the depth of the call stack, or the words of the call at a level.
info level ?LEVEL?
Description
With no LEVEL, gives the level of the running proc: 0 at the global scope, 1 in a proc that the global scope calls, and one more for each call below. A script of uplevel runs at the level that it names, and namespace eval adds no level.
With LEVEL, gives the words of the call of the proc at that level, as a list. A LEVEL above 0 counts from the global scope: 1 is the outermost call. A LEVEL of 0 or less counts back from the running proc: 0 is the running proc, and -1 is its caller. The global scope has no call, so a LEVEL that names it is an error.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| LEVEL | integer | none | The level of the call: from the global scope above 0, from the running proc at 0 or less. |
Returns
The level as an integer, or a list of the words of a call.
Examples
% info level
0
% proc f {a} {info level 0}; f 5
f 5
% proc f {} {info level}; proc g {} {f}; g
2
% proc f {} {info level -1}; proc g {x} {f}; g 7
g 7
% proc f {} {info level 1}; proc g {x} {f}; g 7
g 7
Errors
% info level 1
bad level "1"
-errorcode NONE
% info level 0
bad level "0"
-errorcode NONE
% info level a
expected integer but got "a"
-errorcode TCL VALUE NUMBER
% info level 1 2
wrong # args: should be "info level ?number?"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1