There are a lot of examples of the web of &body
being used in macros. It just can be accessed by ,@body
inside a backquote. But how do we use the &body
lambda-list keyword in functions. I tried to make a number of functions using this keyword, but all they could return me was an error saying
&BODY is not allowed in an ordinary lambda list: (&BODY PIKACHU)
(well, my variable name was pikachu).
(defun tester (&body pikachu)
(mapcar #'+ @pikachu))
Here, I used the @
symbol in front of my pikachu
because I thought that would make my pikachu
into a list (not raichu
). Well, that didn't happen, and I got the same error.
Another version :
(defun tester (&body pikachu)
(mapcar #'+ pikachu))
This too, gave the same error.
And then according to this link, &rest
and &body
are approximately the same, &rest
just takes a list, and &body
takes an implicit progn
of arguments.
And that clarified nothing to be honest. So, I would like to know how exactly &body
works in lisp functions.
&body is a macro lambda list element. You can never use it in a function. &rest is to be used in ordinary functions for the same effect.
If you read the newsgroup thread you link to, you will see the same thing: the only difference between &body
and &rest
is the programmers intent conveyed to the reader.
PS. @
is illegal outside of backquote.