[plt-scheme] load-extension and modules?

From: dvanhorn at emba.uvm.edu (dvanhorn at emba.uvm.edu)
Date: Sat Aug 17 19:54:45 EDT 2002

Quoting Jens Axel Søgaard <jensaxel at soegaard.net>:
> dvanhorn at emba.uvm.edu wrote:
> 
> > I have an extension "x.so" that defines a procedure,
> > #<primitive:x>. I'd like to use the extension in a
> > module, eg.
> >
> > (module m
> >   mzscheme
> >   (provide y)
> >   (load-extension "x.so")
> >   (define (y) (x 1)))
> >
> > is this possible? With this example, I get
> >
> >    STDIN::485: compile: unbound variable in module in: x
> 
> In what namespace does your extension put x?
> 
> --
> Jens Axel Søgaard
> 

I was doing...

Scheme_Object *scheme_initialize(Scheme_Env *env) {
  Scheme_Object *proc;
  proc = scheme_make_prim_w_arity(sch_x, "x", 1, 1);
  scheme_add_global("x", proc, env);
  return scheme_void;
}

Then tried (after reading examples/idmodule.c)...

Scheme_Object *scheme_initialize(Scheme_Env *env) {
  Scheme_Env *menv;
  Scheme_Object *proc;
  menv = scheme_primitive_module(scheme_intern_symbol("x-module"),
				 env);
  proc = scheme_make_prim_w_arity(sch_x, "x", 1, 1);
  mscheme_add_global("x", proc, menv);
  scheme_finish_primitive_module(menv);
  return scheme_void;
}

but,

(module m
  mzscheme
  (provide y)
  (load-extension "x.so")
  (require x-module)
  (define (y) (x 1)))

does not work either. This is my first time writing an extension to mzscheme, btw.

Thanks for the help.
-david





Posted on the users mailing list.