From: Mike Markowski
Subject: how to compile macros
Date: 
Message-ID: <8lnfgr$6ou$1@mahler.udel.edu>
Hi all,

How do I compile and use a macro in GNU clisp?  I did a (defmacro .....)
and the macro seems to work just fine when interpreted.  I can also
compile the file containing the macro defn without any warnings or
errors.  But when I try to use the macro:

Error:

	642 mahler$ clisp pan2 < scloud.pacct-000625.new

	*** - FUNCALL: STREAM-REMEMBER is a macro, not a function

As you can probably guess, I'm new to LISP and am stumped at the
moment.  Any help would be greatly appreciated.

	Thanks!
	Mike

Oh, and if it's helpful, the LISP used (GNU) is:

	643 mahler$ clisp --version
	CLISP 2000-03-06 (March 2000)

From: Tunc Simsek
Subject: Re: how to compile macros
Date: 
Message-ID: <397F4738.F22A2248@robotics.eecs.berkeley.edu>
I don't know if you should be able to funcall a macro but this should
fix your problem:

  instead of (Funcall #'stream-remember ...)

   try (funcall #'(lambda (x)
                    (stream-remember x)) ...)

Regards,
tunc


Mike Markowski wrote:
> 
> Hi all,
> 
> How do I compile and use a macro in GNU clisp?  I did a (defmacro .....)
> and the macro seems to work just fine when interpreted.  I can also
> compile the file containing the macro defn without any warnings or
> errors.  But when I try to use the macro:
> 
> Error:
> 
>         642 mahler$ clisp pan2 < scloud.pacct-000625.new
> 
>         *** - FUNCALL: STREAM-REMEMBER is a macro, not a function
> 
> As you can probably guess, I'm new to LISP and am stumped at the
> moment.  Any help would be greatly appreciated.
> 
>         Thanks!
>         Mike
> 
> Oh, and if it's helpful, the LISP used (GNU) is:
> 
>         643 mahler$ clisp --version
>         CLISP 2000-03-06 (March 2000)
From: Robert Monfera
Subject: Re: how to compile macros
Date: 
Message-ID: <397FA029.3440E5EF@fisec.com>
Tunc Simsek wrote:
> 
> I don't know if you should be able to funcall a macro but this should
> fix your problem:
> 
>   instead of (Funcall #'stream-remember ...)
> 
>    try (funcall #'(lambda (x)
>                     (stream-remember x)) ...)

Or use compiler-macros (albeit some implementations may not be fully
ANSI-compliant).

Robert
From: Tim Bradshaw
Subject: Re: how to compile macros
Date: 
Message-ID: <ey3lmyoab13.fsf@cley.com>
* Mike Markowski wrote:
> Hi all,
> How do I compile and use a macro in GNU clisp?  I did a (defmacro .....)
> and the macro seems to work just fine when interpreted.  I can also
> compile the file containing the macro defn without any warnings or
> errors.  But when I try to use the macro:

You are almost certainly compiling code that uses the macro before the
macro is known to be a macro.  For instance, if you have a file
containing this

(defun foo (x)
  (frobnicate x))

(defmacro frobnicate (x)
  `(car x))

Then FOO will be compiled on the assumption that FROBNICATE is a
function, but FROBNICATE is then defined as a macro, so you'll get
some kind of nasty at runtime.

It's sufficient to either make sure the macro is defined when the code
that uses it is compiled, or to make sure the macro occurs earlier in
a file being compiled than it is used (as the compiler is required to
keep track of macro definitions while compiling a file).

--tim