Take the 2-minute tour ×

I understand that destructuring in LISP macro parameters is a nice thing to have; I am wondering whether it is essential. As an example,

(defmacro m1 (a) (car a))


(defmacro m2 ((a1 a2)) a1)

seem to be (roughly) equivalent - except for checking for the right form of the parameter(s).

My guess is that destructuring makes the code easier to write/understand, but any code using it may be translated into one that does not. Am I right or is this a stupid beginner's mistake?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

It is not essential. You can either let the macro call be destructured by the Lisp system or you write your own code for that inside the macro.

If you would write your own destructuring code you would combine it usually with a &rest or &body parameter list. One usual reason for that is also that the syntax possibilities of the macro lambda list is not flexible enough for a certain purpose. An example for that would be the Common Lisp LOOP macro.

It is good style to use the macro lambda list. It provides an interface with parameters and some structure information. This also allows the Lisp system to provide a simple form of syntactic error checking of macro calls. Something one would have to write by hand.

share|improve this answer
Thanks, this is exactly what I expected - just wanted to make sure. –  mbork Feb 1 '12 at 10:07
add comment

Your Answer


