Lisp HUG Maillist Archive

Returning &whole argument in compiler macros.

Hi all,
  I've just run up against some weird behaviour with compiler macros in LWL 4.4.6
 
  Compiling the following code gives the error,
  LAMBDA-LIST form is not a proper list: #<Quote NIL >.

 (defmacro test-macro (ll &body body)
    `(lambda ,ll ,@body))

 (define-compiler-macro test-macro (&whole form ll &body body)
    (declare (ignore ll body))
    form)

 (defun test-nil ()
    (test-macro () (+ 1 1)))


This only seems to occur with compiler-macro's defined on macros,
defining them on functions still works fine.

Does anyone have any ideas?

Thanks,
   Sean.

Re: Returning &whole argument in compiler macros.

Sean Ross wrote:

> This only seems to occur with compiler-macro's defined on macros,
> defining them on functions still works fine

I'm not sure what you're trying to do here, but I don't think it
makes much sense to define a compiler macro for something that's
already defined as a macro.

You may want to read the 'slides' of the talk that I gave about
compiler macros:

   http://www.pentaside.org/paper/compilermacro-lemmens/compiler-macros-for-publication.txt

Arthur Lemmens


Re: Returning &whole argument in compiler macros.



On 12/19/05, Arthur Lemmens <alemmens@xs4all.nl > wrote:
Sean Ross wrote:

> This only seems to occur with compiler-macro's defined on macros,
> defining them on functions still works fine

I'm not sure what you're trying to do here, but I don't think it
makes much sense to define a compiler macro for something that's
already defined as a macro.

Currently one of the arguments to the macro is a symbol indicating what kind of concurrency
is to be used (it's a simple implementation of the qlisp primitives) and I would much rather decide which form to expand into (when possible) at compile time rather than dispatch at run time.
Granted it can be expanded in the macro it's just that I was quite surprised when returning the
&whole argument caused the macro to break.

Cheers,
  Sean.


Re: Returning &whole argument in compiler macros.

On Mon, 19 Dec 2005 17:21:53 +0100, "Arthur Lemmens" <alemmens@xs4all.nl> wrote:

> I think your mistake is that you're writing a compiler macro for
> something that's already defined as a macro.  Like I said before, I
> think that doesn't make any sense.

The standard explicitely allows compiler macros for macros and I can
imagine there are uses for them.


Re: Returning &whole argument in compiler macros.

On Mon, 19 Dec 2005 17:39:59 +0100, "Arthur Lemmens" <alemmens@xs4all.nl> wrote:

> Ah, OK.  Could you give an example where it makes sense to write a
> compiler macro for a macro instead of for a function?

No, not without thinking about it for which I don't have enough time
at the moment.  With "I can imagine" I meant to say that as a general
rule I assume that the people who designed Common Lisp are probably
smarter than I am.  So, if they explicitely allowed compiler macros
for macros I guess they knew what they were doing.


Re: Returning &whole argument in compiler macros.

On Mon, 19 Dec 2005 17:46:41 +0100, Pascal Costanza <pc@p-cos.net> wrote:

> ...for example, the macro function for the primary macro definition
> could focus on being executed quickly for interpreted code, while
> the compiler macro could invest more overhead for creating an
> efficient macroexpansion for compiled code.

3.2.2.1.3.1 seems to confirm this point of view.


Re: Returning &whole argument in compiler macros.



On 12/19/05, Arthur Lemmens <alemmens@xs4all.nl> wrote:
Pascal Costanza wrote:

>> The standard explicitely allows compiler macros for macros and I can
>> imagine there are uses for them.
>
> ...for example, the macro function for the primary macro definition
> could focus on being executed quickly for interpreted code, while the
> compiler macro could invest more overhead for creating an efficient
> macroexpansion for compiled code.

OK, I see your point.  I must admit that I never think about
interpreted code, but I agree that this could make sense in
certain situations.  (I suspect that Sean's situation is not
one of them.)

No, it's more of a spec issue than an optimization one.


Re: Returning &whole argument in compiler macros.

Unable to parse email body. Email id is 5023

Updated at: 2020-12-10 08:49 UTC