- (walk-form let-body iterate-env
- #'(lambda (form context env)
- (declare (ignore context))
-
- ;; Need to substitute RENAMED-VARS, as well as turn
- ;; (FUNCALL finish-arg) into the finish form
- (cond ((symbolp form)
- (let (renaming)
- (cond ((and (eq form finish-arg)
- (variable-same-p form env
- iterate-env))
- ; An occurrence of the finish
- ; arg outside of FUNCALL
- ; context--I can't handle this
- (maybe-warn :definition "Couldn't optimize iterate form because generator ~S does something with its FINISH arg besides FUNCALL it."
- (second clause))
- (return-from iterate-transform-body
- :abort))
- ((and (setq renaming (assoc form
- renamed-vars
- ))
- (variable-same-p form env
- iterate-env))
- ; Reference to one of the vars
- ; we're renaming
- (cdr renaming))
- ((and (member form bound-vars)
- (variable-same-p form env
- iterate-env))
- ; FORM is a var that is bound
- ; in this same ITERATE, or
- ; bound later in this ITERATE*.
- ; This is a conflict.
- (maybe-warn :user "Couldn't optimize iterate form because generator ~S is closed over ~S, in conflict with a subsequent iteration variable."
- (second clause)
- form)
- (return-from iterate-transform-body
- :abort))
- (t form))))
- ((and (consp form)
- (eq (first form)
- 'funcall)
- (eq (second form)
- finish-arg)
- (variable-same-p (second form)
- env iterate-env))
- ; (FUNCALL finish-arg) =>
- ; finish-form
- (unless (null (cddr form))
- (maybe-warn :definition
- "Generator for ~S applied its finish arg to > 0 arguments ~S--ignored."
- (second clause)
- (cddr form)))
- finish-form)
- (t form)))))
+ (walk-form
+ let-body
+ iterate-env
+ (lambda (form context env)
+ (declare (ignore context))
+
+ ;; We need to substitute RENAMED-VARS, as well as turn
+ ;; (FUNCALL finish-arg) into the finish form.
+ (cond ((symbolp form)
+ (let (renaming)
+ (cond ((and (eq form finish-arg)
+ (var-same-p form env iterate-env))
+ ;; an occurrence of the finish arg outside
+ ;; of FUNCALL context: I can't handle this!
+ (maybe-warn :definition "Couldn't optimize iterate form because generator ~S does something with its FINISH arg besides FUNCALL it."
+ (second clause))
+ (return-from iterate-transform-body
+ :abort))
+ ((and (setq renaming (assoc form renamed-vars))
+ (var-same-p form env iterate-env))
+ ;; Reference to one of the vars
+ ;; we're renaming
+ (cdr renaming))
+ ((and (member form bound-vars)
+ (var-same-p form env iterate-env))
+ ;; FORM is a var that is bound in this same
+ ;; ITERATE, or bound later in this ITERATE*.
+ ;; This is a conflict.
+ (maybe-warn :user "Couldn't optimize iterate form because generator ~S is closed over ~S, in conflict with a subsequent iteration variable."
+ (second clause)
+ form)
+ (return-from iterate-transform-body
+ :abort))
+ (t form))))
+ ((and (consp form)
+ (eq (first form)
+ 'funcall)
+ (eq (second form)
+ finish-arg)
+ (var-same-p (second form) env
+ iterate-env))
+ ;; (FUNCALL finish-arg) => finish-form
+ (unless (null (cddr form))
+ (maybe-warn :definition
+ "Generator for ~S applied its finish arg to > 0 arguments ~S--ignored."
+ (second clause)
+ (cddr form)))
+ finish-form)
+ (t form)))))