Previous: Control Flow, Up: Clauses


2.5 Code Placement

When fine control is desired over where code appears in a loop generated by iterate, the following special clauses may be useful. They are all subject to code-motion problems (see Problems with Code Movement).

— Clause: initially &rest forms

The lisp forms are placed in the prologue section of the loop, where they are executed once, before the loop body is entered.

— Clause: after-each &rest forms

The forms are placed at the end of the loop body, where they are executed after each iteration. Unlike the other clauses in this section, forms may contain iterate clauses.

— Clause: else &rest forms

The lisp forms are placed in the epilogue section of the loop, where they are executed if this else clause is never met during execution of the loop and the loop terminates normally.

— Clause: finally &rest forms

The lisp forms are placed in the epilogue section of the loop, where they are executed after the loop has terminated normally.

— finally-protected: &rest forms

The lisp forms are placed in the second form of an unwind-protect outside the loop. They are always executed after the loop has terminated, regardless of how the termination occurred.