Common Lisp the Language, 2nd Edition

next up previous contents index
Next: User Extensibility Up: Parsing Loop Clauses Previous: Kinds of Loop

26.3.3. Loop Syntax

The following syntax description provides an overview of the syntax for loop clauses. Detailed syntax descriptions of individual clauses appear in sections 26.6 through 26.12. A loop consists of the following types of clauses:

initial-final ::= initially | finally 
variables ::= with | initial-final | for-as | repeat 
main ::= unconditional | accumulation | conditional 
     | termination | initial-final 
loop ::= (loop [named name] {variables}* {main}*)

Note that a loop must have at least one clause; however, for backward compatibility, the following format is also supported:

(loop {tag | expr}*)

where expr is any Common Lisp expression that can be evaluated, and tag is any symbol not identifiable as a loop keyword. Such a format is roughly equivalent to the following one:

(loop do {tag | expr}*)

A loop prologue consists of any automatic variable initializations prescribed by the variable clauses, along with any initially clauses in the order they appear in the source.

A loop epilogue consists of finally clauses, if any, along with any implicit return value from an accumulation clause or an end-test clause.