
LEVEL - substitution depth of identifiers

Calling sequence:
LEVEL := integer

Parameter:

integer   --  positive integer

Summary:

LEVEL gives the maximum substitution depthfor identifiers in expressions.
Before an expression is evaluated the substitution depth is 0. If an identifier
is replaced by its value during evaluation then the substitution depth is
increased by 1 and the value of the identifier is evaluated with this depth.
After the value has been evaluated the substitution depth is decreased by 1.

If the maximum substitution depth of LEVEL is reached during evaluation
then the identifier is evaluated no further. On the interactive level LEVEL has
the default value 100.  Before the execution of a procedure LEVEL is set to
1. Thus, in procedures, variables are only substituted once. This is valid as
long as LEVEL is not changed. After a procedure is exited LEVEL is reset to
its original value. The substitution depth can also be influenced by using the
function level .

If during evaluation the substitution depth MAXLEVEL  is reached then an

error message is given and the evaluation is terminated. This is an heuristic
for recognizing recursive definitions, as in a := NIL; a := a; a;. (Here a
is  infinitely\ substituted by a.)  If MAXLEVEL is greater than LEVEL then
rec"ursive definitions are not recognized.

The environment variableLEVEL can be set to any integer between 1 and 231-
1.  With the assignment LEVEL := NIL;, LEVEL is set to the default value
100 on the interactive level.

>>  a1:=b1: b1:=c1: c1:=7: a1;

      7

>>  a2:=b2: b2:=c2: c2:=7: LEVEL:=2: a2;

      c2

>>  a3:=b3: b3:=c3: c3:=7: MAXLEVEL:=2: LEVEL:=2: a3;

      Error: Recursive definition

See also:  MAXLEVEL , level

