macro returning more than one form

Pascal J. Bourguignon pjb at informatimago.com
Fri Mar 14 16:57:20 UTC 2014


Paul Tarvydas <paultarvydas at gmail.com> writes:

> What is the best way to write a macro that returns more than one form
> to the top level?  E.g.
>
> (in-package :xxx)
> (defun ...)
>
> I've been wrapping a progn around the result, but LW doesn't like it
> very much, and SBCL seems to hate it.


(defmacro this-works-but-it-s-bad-form-to-mix-in-package-with-other-things ()
 (let ((package :xxx))
   `(progn
     (in-package ,package)
     (defun ,(intern "FNAME" package) (x)
        (if (< x 1)
            1
            (* x (,(intern "FNAME" package) (1- x))))))))



-- 
__Pascal Bourguignon__
http://www.informatimago.com/
"Le mercure monte ?  C'est le moment d'acheter !"



More information about the pro mailing list