Rivka Miller <[email protected]> writes:

> I still need someone to help me get the common-lisp comprehension code
> working on emacs.

Require cl and use defmacro* instead of defmacro:


(require 'cl)
(defmacro* comp ((e &rest qs) l2)
  (if (null qs) `(cons ,e ,l2)    ; rule A
      (let ((q1 (car qs))
            (q (cdr qs)))
        (if (not(eq (cadr q1) '<-)) ; a generator?
            `(if ,q1 (comp (,e ,@q),l2) ,l2) ; rule B
            (let ((v (car q1))      ; rule C
                  (l1 (third q1))
                  (h (gentemp "H-"))
                  (us (gentemp "US-"))
                  (us1 (gentemp "US1-")))
              `(labels ((,h (,us)     ; corresponds to a letrec
                          (if (null ,us) ,l2
                              (let ((,v (car ,us))
                                    (,us1 (cdr ,us)))
                                (comp (,e ,@q) (,h ,us1))))))
                 (,h ,l1)))))))

(macroexpand '(comp (e (< 1 2)) l2))
--> (if (< 1 2) (comp (e) l2) l2)
(macroexpand '(comp (e) l2))
--> (cons e l2)

-- 
__Pascal Bourguignon__
http://www.informatimago.com
_______________________________________________
gnu-emacs-sources mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnu-emacs-sources

Reply via email to