6.1. The LOOP Facility [sec_6-1]

6.1.1. Mixing Termination Test Clauses sec_6-1-4
6.1.2. Iteration variables in the loop epilogue
6.1.3. Backward Compatibility

6.1.1. Mixing Termination Test Clauses [sec_6-1-4]

Mixing termination test clauses with different default return values is not allowed because it is not specifed whether

(loop repeat 1 thereis nil never nil)

should return T (the default return value from NEVER) of NIL (the default return value from THEREIS).

6.1.2. Iteration variables in the loop epilogue

The standard is unambiguous in that the iteration variables do still exist in the FINALLY clause, but not as to what values these variables might have. Therefore the code which relies on the values of such variables, e.g.,

(loop for x on y finally (return x))

is inherently non-portable across Common Lisp implementations, and should be avoided.

6.1.3. Backward Compatibility

There have been some tightening in the LOOP syntax between [CLtL2] and [ANSI CL standard], e.g., the following form is legal in the former but not the latter:

(loop initially for i from 1 to 5 do (print i) finally return i)

When CUSTOM:*LOOP-ANSI* is NIL, such forms are still accepted in CLISP but elicit a warning at macro-expansion time. When CUSTOM:*LOOP-ANSI* is non-NIL, an ERROR is SIGNALed.


These notes document CLISP version 2.49.93+Last modified: 2018-02-19