[cmucl-help] Re: Compiling macros with an optional function parameter?

2008-09-24 Thread Willem Broekema
On Wed, Sep 24, 2008 at 9:06 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> What I don't understand, though, is why the original macro compiled and
> ran without this problem (it was only during concatenation into a larger
> binary when this error occurred).

In general, dumping a literal function object into a fasl file is not
something you can rely on. See CLHS section 3.2.4.2.2, where it says
for functions that they are "not externalizable objects". That means a
macro should not expand into source code that includes a literal
function object, but instead to its name (as you have found) or e.g. a
lambda form.

Similarly you can't just dump an instance of a class, so a macro
expansion should not include a literal instance, unless there is a
make-load-form method.

- Willem
(resent from address that is subscribed to the list, sorry for any duplicates)



[cmucl-help] Re: Compiling macros with an optional function parameter?

2008-09-24 Thread [EMAIL PROTECTED]
Christophe Rhodes wrote:
> Your macro expands to source code which contains a literal function
> object in it.  Instead, you want to expand into source code which
> contains something which will retrieve the function object.  The usual
> error is to provide a default for a parameter which ends up being
> unquoted such as #'foo, where you should actually provide '#'foo.
> (You could also provide ''foo as the default).

Thanks for the explanation; using '#'string-equal as the optional
parameter default solved it.

What I don't understand, though, is why the original macro compiled and
ran without this problem (it was only during concatenation into a larger
binary when this error occurred).



[cmucl-help] Re: Compiling macros with an optional function parameter?

2008-09-24 Thread Christophe Rhodes
"Denis Papathanasiou" <[EMAIL PROTECTED]> writes:

> I'm not sure if this is a Lisp thing or an issue specific to CMUCL,
> but when I compile this macro and try to include the resulting x86f
> file into a larger binary (i.e. using 'cat'), I see this: "Error in
> batch processing: Cannot dump objects of type FUNCTION into fasl
> files."

Your macro expands to source code which contains a literal function
object in it.  Instead, you want to expand into source code which
contains something which will retrieve the function object.  The usual
error is to provide a default for a parameter which ends up being
unquoted such as #'foo, where you should actually provide '#'foo.
(You could also provide ''foo as the default).

Best,

Christophe



[cmucl-help] Re: Compiling macros with an optional function parameter?

2008-09-24 Thread [EMAIL PROTECTED]
Raymond Toy wrote:
> I think you should change #'string-equal to 'string-equal.

That won't compile b/c the macro-expansion doesn't come out right (it
winds up as ":test string-equal" instead of ":test #'string-equal").

Note that the macro as originally written *does* work, both in
interpreted and compiled forms.

It's just when I try to cat the x86f file into another one (I'm creating
a single x86f file composed of different macros & functions), that
concatenation won't work.





[cmucl-help] Re: Compiling macros with an optional function parameter?

2008-09-24 Thread Raymond Toy
Denis Papathanasiou wrote:
> I'm not sure if this is a Lisp thing or an issue specific to CMUCL,
> but when I compile this macro and try to include the resulting x86f
> file into a larger binary (i.e. using 'cat'), I see this: "Error in
> batch processing: Cannot dump objects of type FUNCTION into fasl
> files."
> 
> This is the macro:
> 
> (defmacro update-list-hash (hash data-key data-value &optional
> (test-fn #'string-equal))

I think you should change #'string-equal to 'string-equal.

Ray