TAL Programmer's Guide

FOR Statement
Controlling Program Flow
12–16 096254 Tandem Computers Incorporated
Optimized FOR Loop Execution
The execution of optimized FOR loops differs from standard FOR loops as follows:
When the looping terminates, index is equal to limit.
limit is calculated only once—at the start of the first time through the loop.
The following example compares the value of index in standard and optimized FOR
loops:
PROC a MAIN;
BEGIN
INT i, j, k;
FOR i := 1 TO 10 DO k := i; !Standard FOR loop
k := i; !K is 11
USE j;
FOR j := 1 TO 10 DO k := j; !Optimized FOR loop
k := j; !K is 10
DROP j;
END;