From: JP Massar
Subject: Question about Ansi CL DEFINE-COMPILER-MACRO
Date: 
Message-ID: <3b8419eb.65937948@news>
Consider the following code:

---------------------

(in-package :user)

(define-compiler-macro foo (&whole form a b)
  (print form)
  )

(defun test4 ()
  (list (foo 1 2) (funcall #'foo 1 2)))

----------------------


If one compiles the DEFINE-COMPILER-MACRO form, then compiles TEST4,
assuming the compiler chooses to use the compiler macro so defined,
should the compilation of TEST4 result in the printing of

(foo 1 2)
(foo 1 2)

or should it result in

(foo 1 2)
(funcall (function foo) 1 2)


Thanks.

From: Kent M Pitman
Subject: Re: Question about Ansi CL DEFINE-COMPILER-MACRO
Date: 
Message-ID: <sfwn14ryb0a.fsf@world.std.com>
······@alum.mit.edu (JP Massar) writes:

> Consider the following code:
> 
> ---------------------
> 
> (in-package :user)
> 
> (define-compiler-macro foo (&whole form a b)
>   (print form)
>   )
> 
> (defun test4 ()
>   (list (foo 1 2) (funcall #'foo 1 2)))
> 
> ----------------------
> 
> If one compiles the DEFINE-COMPILER-MACRO form, then compiles TEST4,
> assuming the compiler chooses to use the compiler macro so defined,
> should the compilation of TEST4 result in the printing of
> 
> (foo 1 2)
> (foo 1 2)
> 
> or should it result in
> 
> (foo 1 2)
> (funcall (function foo) 1 2)
> 
> Thanks.

The spec seems vague on it.  I'd say the conservative thing is to check.
The only valid use for form without checking would be simply to return
as an "I don't have an expansion" value; but if you're going to pick it
apart, I'd start with checking whether its car was the op you expected or
whether it was somethingn like APPLY or FUNCALL.  Better to be safe than
sorry.
From: Geoff Summerhayes
Subject: Re: Question about Ansi CL DEFINE-COMPILER-MACRO
Date: 
Message-ID: <toaalvmmsm9kb7@corp.supernews.com>
"Kent M Pitman" <······@world.std.com> wrote in message
····················@world.std.com...
>
> The spec seems vague on it.  I'd say the conservative thing is to
check.
> The only valid use for form without checking would be simply to return
> as an "I don't have an expansion" value; but if you're going to pick
it
> apart, I'd start with checking whether its car was the op you expected
or
> whether it was somethingn like APPLY or FUNCALL.  Better to be safe
than
> sorry.

I just played with DEFINE-COMPILER-MACRO using LW personal,
this thread made me curious. :-)
The first example in the hyperspec gave this result:

CL-USER 19 > (funcall (compiler-macro-function 'square) '(funcall
#'square x) nil)

Error: syntax error in (FUNCALL (FUNCTION SQUARE) X):
The call (FUNCALL (FUNCTION SQUARE) X) does not match the definition
(FUNCALL ARG).
  1 (abort) Return to level 0.
  2 Return to top loop level 0.

Is this a bug in the Hyperspec or a bug in LW?

------
Geoff

11. Monty Python Comments: On a method called makeSnafucated
insert only the comment /* make snafucated */. Never define what
snafucated
means anywhere. Only a fool does not already know, with complete
certainty,
what snafucated means. For classic examples of this technque, consult
the
Sun AWT JavaDOC. --"How to write unmaintainable code"  - Roedy Green