chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] How to load modules for compilation


From: Peter Bex
Subject: Re: [Chicken-users] How to load modules for compilation
Date: Mon, 6 Oct 2014 15:53:17 +0200
User-agent: Mutt/1.4.2.3i

On Mon, Oct 06, 2014 at 03:44:38PM +0200, Sascha Ziemann wrote:
> But when I try to compile it I get an error:
> 
> $ csc -R blowfish -ss curtain.scm
> 
> Error: during expansion of (curtain ...) - unbound variable:
> blowfish#make-blowfish-encryptor

> I am wondering why the blowfish function is unbound although I have
> specified the module. Can anybody give me a hint what I did wrong?

Hello Sascha,

You can do (begin-for-syntax (require-extension blowfish)) to make
it available at macro expansion/compilation time.  Having the
require-extension at toplevel will cause the extension to be
loaded when the program is executed, but you want it to be loaded
into the compiler, too.

The reason this works in the interpreter is that compilation and
evaluation are intertwined: it reads one toplevel form at a time,
and macro-expands and evaluates it immediately.  That means the
macro-expander has the library available after require-extension
is evaluated.  When compiling code, the separation is strict: the
forms are read in and macro-expanded one by one, and compiled down
to C, but toplevel forms are never evaluated; that is done only
at runtime.  Everything inside begin-for-syntax *will* be evaluated
at compilation time.

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



reply via email to

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