Next: , Up: Unconditional Execution   [Contents][Index]


15.25.11.1 do - doing

do {expr}*
doing {expr}*
do

construct simply evaluates the specified expressions wherever they occur in the expanded form of loop.

expr

argument can be any non-atomic Common Lisp form. Each expr is evaluated in every iteration.

Constructs with Arbitraty Number of Forms

The constructs

are the only loop keywords that take an arbitrary number of forms and group them as if using an implicit progn.

Because every loop clause must begin with a loop keyword, you would use the keyword ‘do’ when no control action other than execution is required.

Examples

;;; Print some numbers.
(loop for i from 1 to 5
      do (print i)) ;Prints 5 lines
;;; Print numbers and their squares.
;;; The DO construct applies to multiple forms.
(loop for i from 1 to 4
      do (print i)
         (print (* i i))) ;Prints 8 lines