+---------------
| It is dangerous (just plainly not conforming) to expect the loop
| variables to be available or to have any specific or valid value
| in the epilog.
+---------------
Hmmm... That contradicts my reading of the CLHS:
6.1.2.1 Iteration Control
...
All variables are initialized in the loop prologue.
A variable binding has lexical scope unless it is
proclaimed special; thus, by default, the variable
can be accessed only by forms that lie textually
within the loop.
Since any FINALLY clause is still within the LOOP, I would
expect any variables introduced by FOR/AS/AND/etc. to still
be visible in the FINALLY clause.
Now with respect to Sam Steingold's other question, about
the difference in returned values between CLISP and SBCL:
(loop for c from 0 to 1 for i on '(1 2 3 4 5) finally (return i))
==> (3 4 5) ; CLISP
==> (2 3 4 5) ; SBCL
This appears to be a difference in when the variable I is
"stepped", specifically, whether it is assigned the next value
in the iteration *before* or *after* the termination test is
performed. It would appear that CLISP is stepping *before*
the termination test, whereas SBCL (and CMUCL) are stepping
*afterwards*, and then only if the termination test fails.
CLHS 6.1.2.1 "Iteration Control" may also give some guidance
on this, when it says this:
If multiple iteration clauses are used to control iteration,
variable initialization and stepping[1] occur sequentially
by default.
That would imply that CLISP is incorrect in the above example,
since the variable I should not have been stepped again when the
loop terminated on the test of C. Compare with this, which uses
AND instead of FOR to force parallel evaluation in the second
iteration clause:
(loop for c from 0 to 1 AND i on '(1 2 3 4 5) finally (return i))
==> (3 4 5) ; CMUCL [SBCL will probably yield the same]
-Rob
-----
Rob Warnock <
rp...@rpw3.org>
627 26th Avenue <
http://rpw3.org/>
San Mateo, CA 94403