2 Loop Constructs

2.2 Iteration control

Iteration control clauses allow you to direct loop iteration. The following loop keywords designate iteration control clauses:

as
for
repeat 

Iteration control clauses differ with respect to the specification of termination conditions and to the initialization and stepping of loop variables. Iteration clauses by themselves do not cause the Loop Facility to return values, but they can be used in conjunction with value-accumulation clauses to return values. See Section 2.4 on page 24 for more information on using value-accumulation clauses.

All variables are initialized in the loop prologue. The variable binding has lexical scope unless it is proclaimed special; thus, the variable can be accessed only by expressions that lie textually within the loop. Stepping assignments are made in the loop body before any other expressions are evaluated in the body.

The variable argument in iteration control clauses can be a destructuring list. A destructuring list is a tree whose nonnull atoms are symbols that can be assigned a value. See Section 2.8.2 on page 39 for information and examples.

The iteration control clauses for, as, and repeat must precede any other loop clauses, exceptinitially,finally,with, andnodeclare since they establish variable bindings. When iteration control clauses are used in a loop, termination tests in the loop body are evaluated before any other loop body code is executed.

2.2.1 - Using multiple iteration clauses
2.2.2 - Reference pages

The Loop Facility - 9 SEP 1996

Generated with Harlequin WebMaker