The Common Lisp ITERATE macro

Cannot use macrolet inside iterate forms

Reported by Patrick Stein on 2012-06-08
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ITERATE macro
Undecided
Unassigned

Bug Description

From the iterate website: http://common-lisp.net/project/iterate/bugs.html

==========================================
(iterate (for i from 0 to 20)
         (macrolet ((collect-if-divisible (variable divisor result-var)
        `(when (zerop (mod ,variable ,divisor))
    (collect ,variable into ,result-var))))
           (collect-if-divisible i 3 result-3)
    (collect-if-divisible i 5 result-5))
      (finally (return (values result-3 result-5))))

would be nice to have. Currently has to be rewritten:

(macrolet ((collect-if-divisible (variable divisor result-var)
     `(when (zerop (mod ,variable ,divisor))
    (collect ,variable into ,result-var))))
  (iterate (for i from 0 to 20)
           (collect-if-divisible i 3 result-3)
    (collect-if-divisible i 5 result-5)
    (finally (return (values result-3 result-5)))))

of course, this does not work in all cases.
==========================================

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers