[pro] Keyword arguments and compiler macros

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Fri Dec 2 19:42:46 UTC 2011


On Fri, Dec 2, 2011 at 7:27 PM, Scott L. Burson <Scott at sympoiesis.com>wrote:

> To put it another way: by your argument, I think the answer to
> Juanjo's question doesn't matter very much.
>

I think it does. What Nikodemus is arguing *is orthogonal to what I am
saying*. One thing is whether keyword argument parsing of compiler macros
is insuficient and whether one has to use &rest and ensure that the order
is ok. I am fine with it.

A different issue is the utility of &key. I do not buy the argument that
&key should always be used with &allow... in compiler macros. This forfeits
any use of &key at all because the values are _never_ going to be trusted
at all: one of the arguments might be a variable name and the parser will
confuse the user about expectations.

More precisely, if I write

(define-compiler-macro foo (&rest my-args &key some-key-arg
&allow-other-keys) ...)

and write (foo :some-key-arg some-value some-variable some-other-value) the
parser is going to produce a useless value in some-key-arg. That means I
have to do my own parsing of my-args to see whether the keyword arguments
are to be trusted.

If on the other hand this definition

(define-compiler-macro foo (&rest my-args &key some-key-arg) ...)

implies that the compiler macro will refuse parsing (without an error) when
some argument is not an allowed keyword, then this actually has some
utility.

Regarding the issue of argument ordering and other stuff, there are many
cases where I want to write compiler macros for the case in which the
arguments are simple forms. This case is very simple to check and means
that &key arguments have a value by themselves.

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/pro/attachments/20111202/b8514af8/attachment.html>


More information about the pro mailing list