From: Rob Warnock on
Captain Obvious <udodenko(a)users.sourceforge.net> wrote:
+---------------
| (macrolet ((defuns (lst)
| `(progn ,@(loop for form in lst
| collect `(my-defun ,form))))
| (defuns ((f1 1) (f2 2) (f3 3)))
+---------------

While in some cases there might be something to be gained
from the inner list, in this case simply using a &REST parameter
is better IMHO:

(macrolet ((defuns (&rest forms)
`(progn ,@(loop for form in forms
collect `(my-defun ,form)))))
(defuns (f1 1) (f2 2) (f3 3)))

Further, if you redefine MY-DEFUN to take its args directly instead
of with a single list arg that needs to be destructured, you can let
the outer MACROLET do the destructuring for you:

> (defmacro my-defun (name &rest rest)
`(defun ,name ()
(list ,@rest)))

MY-DEFUN
> (macrolet ((defuns (&rest forms)
`(progn ,@(loop for (name . args) in forms
collect `(my-defun ,name ,@args)))))
(defuns (f1 1) (f2 2 4) (f3 3 6 9)))

F3
> (f1)

(1)
> (f2)

(2 4)
> (f3)

(3 6 9)
>


-Rob

-----
Rob Warnock <rpw3(a)rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607

First  |  Prev  | 
Pages: 1 2 3
Prev: ABCL 0.21 released
Next: Do we need a "Stevens" book?