While testing out a loop on various implementations I came across the
following discrepancy (boiled down):
(loop repeat 3 for x from 0 finally (return x))
=> 2 in CMUCL, SBCL, and Allegro CL
=> 3 in CLISP
For the first 3 implementations, x is no longer incremented once the
termination test of repeat has been reached, but for CLISP it is still
incremented (whether before or despite the termination-test I do not
If you change the order of the repeat and the for-from clauses in the
loop, then CMUCL, SBCL, and Allegro give 3 as a result as well. So my
guess is that those are applying the repeat termination-test in the
order that it appears with the iteration-control clauses.
The Hyperspec, section 22.214.171.124 "Order of Execution", states that:
``* Iteration control clauses implicitly perform the following actions:
-- initialize variables;
-- step variables, generally between each execution of the loop body;
-- perform termination tests, generally just before the execution of the
Section 6.1.4 "Termination-test Clauses" states:
`` Termination-test control constructs can be used anywhere within the
loop body. The termination tests are used in the order in which they
Does this mean that all stepping of variables should occur before any
termination-tests are performed--regardless of lexical position--or only
before termination-tests associated with the iteration-control clauses?
; Matthew Danish <mdan...@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."