[plt-scheme] How do i make a native extension behave like a module?

From: Henrik Tramberend (henrik.tramberend at inform.fh-hannover.de)
Date: Thu Aug 19 07:11:41 EDT 2004

Hello,

i am currently working on an extension that i want to load as a module 
via (require) and not directly via (load-extension). From the 'Inside 
MzScheme' documentation i gather that the C init code of the extension 
has to look approximately like this:

Scheme_Object *scheme_initialize(Scheme_Env *env) {

   Scheme_Object * open = scheme_make_prim_w_arity(&open, "open", 1 ,1);

   Scheme_Env * module =
	scheme_primitive_module(scheme_make_string("module-name"), env);

   scheme_add_global("open", open, module);

   scheme_finish_primitive_module(module);
	
   return scheme_null;
}

Scheme_Object *scheme_reload(Scheme_Env *env) {
   return scheme_initialize(env);
}

Scheme_Object *scheme_module_name() {
   return scheme_make_string("module-name");
}

Is this the way to do it? If yes, how do i 'require' such a native 
module? That is the part i am somehow missing. If this approach is 
altogether wrong, can someone please point me into the right direction?

Thanks for any help.

Henrik




Posted on the users mailing list.