[plt-scheme] loading extension in a module

From: Daniel Silva (daniel.silva at gmail.com)
Date: Tue Nov 30 03:34:41 EST 2004

On 29 Nov 2004 20:42:15 -0800, Ian Zimmerman <itz at buug.org> wrote:
> Daniel> To write your C extension as a module, you create a module
> Daniel> namespace with scheme_primitive_module, then add your primitives
> Daniel> to it, and finally close the namespace with
> Daniel> scheme_finish_primitive_module:
> 
> But this is not what I want to do.  It could be a possible workaround,
> but before I go into workarounds I want to know if my original intent is
> doable and how.

Ok.  If you want to use load-extension or load-relative-extension,
then I think you will need to refer to imported primitives through
namespace-variable-value.

Since load-extension is evaluated at runtime and your module is
checked for free variables at compile time, the checker doesn't find
the bindings for your C primitives and signals an error.  Try adding
the following:

(load-relative-extension "plt_stat.so")
(define c-lstat (namespace-variable-value 'c-lstat))

If namespace-variable-value doesn't cut it, then eval will probably do the job.

Daniel


Posted on the users mailing list.