Subject: Re: Question about lisp macros
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 02 Feb 2005 05:56:23 -0600
Newsgroups: comp.lang.lisp
Message-ID: <W6SdnYyDZNR6Ip3fRVn-1w@speakeasy.net>
Andreas Thiele <nospam@nospam.com> wrote:
+---------------
| A macro cannot be called like a function.
| (funcall macro-symbol ...
| is not possible
+---------------

Well, you *can*, but the macro function probably isn't what you'd
think it would be from looking at the DEFMACRO form. For one thing,
it always takes exactly two arguments (&whole form &environment env),
not whatever args the DEFMACRO had:

    > (defmacro foo (a b c)
	`(list ',a ,b ,(1+ c)))

    FOO
    > (macro-function 'foo)

    #<Interpreted Function "DEFMACRO FOO" {48536BA1}>
    > (describe *)

    #<Interpreted Function "DEFMACRO FOO" {48536BA1}> is function.
    Arguments:
      (A B C)
    Its defined argument types are:
      (T T)
    Its result type is:
      *
    Its definition is:
      (LAMBDA (#:WHOLE-984 #:ENV-985) (DECLARE #) (BLOCK FOO #))
    > (funcall ** '(foo bar 1 2) nil)

    (LIST 'BAR 1 3)
    > 

[Note that I gave NIL here for the environment, since I don't know
how to hand-craft a CMUCL macro environment.]


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607