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

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to