Next: User Extensibility, Previous: How the Loop Facility Works, Up: Loop [Contents][Index]
The syntactic parts of a loop construct are called clauses; the scope of each clause is determined by the top-level parsing of that clause’s keyword.
(loop for i from 1 to (compute-top-value) ;First clause
while (not (unacceptable i)) ;Second clause
collect (square i) ;Third clause
do (format t "Working on ~D now" i) ;Fourth clause
when (evenp i) ;Fifth clause
do (format t "~D is a non-odd number" i)
finally (format t "About to exit!")) ;Sixth clause
Each loop keyword introduces either
The number of forms in a clause is determined by the loop keyword that begins the clause and by the auxiliary keywords (“prepositions”) in the clause.
The keywords
do,
initially, and
finally
are the only loop keywords that can take any number of Lisp forms and group
them as if in a single progn form.
Loop clauses can contain auxiliary keywords, which are sometimes called prepositions.
from and to, which mark the value from which stepping
begins and the value at which stepping ends.
Next: User Extensibility, Previous: How the Loop Facility Works, Up: Loop [Contents][Index]