beetlebug▾
/

interp recursionlimit

Reads or sets the nesting limit of an interpreter.

interp recursionlimit PATH ?LIMIT?

Description

With no LIMIT, gives the nesting limit of the interpreter of PATH: the deepest nesting of calls of procs and of eval, uplevel, and the other commands that run a script. The default is 600. With LIMIT, sets it and gives it.

LIMIT is 1 or more, and at most the limit of the current interpreter, so a child never gets a deeper nesting than its parent. A script that goes past the limit stops with the error too many nested evaluations (infinite loop?), and catch stops that error.

Arguments

ArgumentTypeDefaultDescription
PATHinterpreter pathrequiredThe interpreter, {} for the current one.
LIMITinteger, 1 or morenoneThe new nesting limit.

Returns

The nesting limit.

Examples

% set c [interp create]; interp recursionlimit $c
600

% interp recursionlimit $c 20
20

% interp eval $c {proc f {n} {f [incr n]}; catch {f 0} m; set m}
too many nested evaluations (infinite loop?)

Errors

% interp recursionlimit $c 0
recursion limit must be > 0
-errorcode NONE

% interp recursionlimit $c x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

# A child cannot go deeper than its parent.
% interp recursionlimit $c 700
the recursion limit of this interpreter is 600
-errorcode NONE

% interp recursionlimit $c 5 6
wrong # args: should be "interp recursionlimit path ?newlimit?"
-errorcode TCL WRONGARGS

Facts

Capability
interp. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also