[Top][All Lists]

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

Re: [Chicken-users] require-extension does not work in compiled code?

From: felix winkelmann
Subject: Re: [Chicken-users] require-extension does not work in compiled code?
Date: Sun, 5 Dec 2004 14:55:35 +0100

On Sun, 5 Dec 2004 08:45:07 -0500, Michele Simionato
<address@hidden> wrote:
> I am using Chicken 1.74 and I have found a surprising (for me) behavior of
> require-extension in compiled code. Consider the following two files:
> $ cat mylib.scm
> (require-extension regex)
> (print  "string-match is there" string-match)
> $ cat main.scm
> (require-extension mylib)
> In the interpreter, nothing strange happens:
> $ csi -script main.scm
> string-match is there#<procedure>
> However if I compile I get the following:
> $ csc main; main
> Error: unbound variable: regex
> ##sys#require
> The same happens if I import srfi-1 or other extensions I tried.
> Is this right? What should I do? The error message is rather
> cryptic ...

The `(require-extension mylib)' is not completely correct.
`require-extension' is intended to load centrally registered
extensioni libraries and core library units on demand.
It happens to work for .scm files, when they are accessible
in the current include path.
The `(require-extension mylib)' in the example above finds the
local mylib.scm and loads/evaluates it. But the evaluator in
compiled code supports only the most basic syntactic forms
(and not `require-extension'). In that case require-extension is
treated as any other function call, it's arguments are evaluated,
and... the variable `regex' is not defined.
You can use `(require 'regex)' instead, or you can compile mylib
to a shared object (csc mylib.scm -s) - require extension will
find and load the .so, and compiled code has access to all
extra macros.


reply via email to

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