Next: , Previous: , Up: Iteration Control   [Contents][Index]


15.25.6.5 ’for-as-equals-then’

This is the fourth of seven ‘for/as’ syntaxes.

for var [type-spec] = expr1 [then expr2]
 as var [type-spec] = expr1 [then expr2]

This construct

;;; Sample original code:
(loop for x = expr1 then expr2 do (print x))

;;; The usual expansion:
(tagbody
      (setq x expr1)
  tag (print x)
      (setq x expr2)
      (go tag))

;;; The optimized expansion:
(tagbody
  tag (setq x expr1)
      (print x)
      (go tag))
;;; Collect some numbers.
(loop for item = 1 then (+ item 10) repeat 5 collect item)