chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Macros and loading compiled code


From: Peter Bex
Subject: Re: [Chicken-users] Macros and loading compiled code
Date: Wed, 10 Sep 2014 10:47:02 +0200
User-agent: Mutt/1.4.2.3i

On Wed, Sep 10, 2014 at 12:01:54AM -0700, alex wrote:
> Hi,

Hello Alex,

> I defined a macro. I compiled it separately and built it into my main 
> program. When my main program calls the load procedure on normal Scheme 
> source files, the procedures in these files use the macro without 
> complaint.
> 
> However, when it loads the dynamic object code created from compiling 
> those same source files, I get an error about an "unbound value" in a 
> subexpression of a macro expression. This seems to be because the macro 
> expressions are being evaluated as normal procedure applications. If I 
> insert the macro definition verbatim into each source file before I 
> compile it, the errors do not occur.

I'm having a hard time picturing exactly what you're doing, so it would
be nice if you could show us some code along with the csi/csc commands
you've tried (it doesn't have to be exactly your code; in fact, a
simplified "dummy" example is preferable).

One important thing to remember about macros is that they must be
available at compile time, not at runtime.  For example, you can't use
(load "...") to load the code for the macro in a script you're compiling,
but it _will_ work if you interpret the same script because every
expression will be evaluated one-by-one, whereas the compiler will read
and macro-expand all the forms before compiling them, without evaluating
them.  This can sometimes be a little confusing.

Cheers,
Peter
-- 
http://www.more-magic.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]