I found this macro-lambda-list in a lisp source file written by Edi Weitz.
(defmacro insert-char-class-tester ((char-class chr-expr) &body body)
^^^^^^^^^^^^^^^^^^^^^
I can't see how this definition conforms to the hyperspec:
http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm
reqvars::= var*
Is this form often used in macro-definitions??
On Jan 31, 1:13 pm, Michael Bohn <············@gmx.de> wrote:
> I found this macro-lambda-list in a lisp source file written by Edi Weitz.
>
> (defmacro insert-char-class-tester ((char-class chr-expr) &body body)
> ^^^^^^^^^^^^^^^^^^^^^
> I can't see how this definition conforms to the hyperspec:
>
> http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm
> reqvars::= var*
>
> Is this form often used in macro-definitions??
This is covered by the second-to-last paragraph, the one before it,
and 3.4.4.1.
The (char-class chr-expr) is taken in the place of a parameter name,
to be a destructuring lambda list. The situation is not ambiguous
because the syntax does not otherwise allow a compound form there.
Michael Bohn <············@gmx.de> writes:
> I found this macro-lambda-list in a lisp source file written by Edi Weitz.
>
> (defmacro insert-char-class-tester ((char-class chr-expr) &body body)
> ^^^^^^^^^^^^^^^^^^^^^
> I can't see how this definition conforms to the hyperspec:
>
> http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm
> reqvars::= var*
>
> Is this form often used in macro-definitions??
Macro lambda lists are destructuring; see 3.4.4.1. It is used very
frequently.
Zach
Michael Bohn wrote:
> I found this macro-lambda-list in a lisp source file written by Edi Weitz.
>
> (defmacro insert-char-class-tester ((char-class chr-expr) &body body)
> ^^^^^^^^^^^^^^^^^^^^^
> I can't see how this definition conforms to the hyperspec:
>
> http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm
> reqvars::= var*
Not sure about how to read grammars, but he is using "destructuring by
lambda lists":
http://www.lispworks.com/documentation/HyperSpec/Body/03_dda.htm
>
> Is this form often used in macro-definitions??
Absolutely, and it is one of coolest things about macro writing that one
can easily offer the kind of structure you find in defclass in your own
macros. This is part of how "code as data" pays off, and one of the
things that would make macro-writing in other languages quite hard.
kt
--
Well, I've wrestled with reality for 35 years, Doctor, and
I'm happy to state I finally won out over it.
-- Elwood P. Dowd
In this world, you must be oh so smart or oh so pleasant.
-- Elwood's Mom
(message (Hello 'Michael)
(you :wrote :on '(Wed, 31 Jan 2007 22:13:55 +0100))
(
MB> I found this macro-lambda-list in a lisp source file written by Edi
MB> Weitz.
MB> (defmacro insert-char-class-tester ((char-class chr-expr) &body body)
MB> ^^^^^^^^^^^^^^^^^^^^^
MB> I can't see how this definition conforms to the hyperspec:
MB> http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm
MB> reqvars::= var*
and why do you think var is an atom here? read more careful!
Destructuring allows a macro lambda list to express the structure of a macro
call syntax.
http://www.lispworks.com/documentation/HyperSpec/Body/03_dda.htm
3.4.4.1 Destructuring by Lambda Lists
Anywhere in a macro lambda list where a parameter name can appear, and where
ordinary lambda list syntax (as described in Section 3.4.1 (Ordinary Lambda
Lists)) does not otherwise allow a list, a destructuring lambda list can
appear in place of the parameter name. When this is done, then the argument
that would match the parameter is treated as a (possibly dotted) list, to be
used as an argument list for satisfying the parameters in the embedded
lambda list. This is known as destructuring.
MB> Is this form often used in macro-definitions??
yes
)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity")