[plt-scheme] modules and extensions

From: Phil Windley (phil at windley.org)
Date: Wed Jun 8 16:47:54 EDT 2005

I'm trying to get around some namespace issue with an extension and  
went down a rabbit hole of defining modules from extensions.  I've  
pieced together stuff from the Web and http://download.plt-scheme.org/ 
doc/299.100/html/insidemz/insidemz-Z-H-2.html#node_sec_2.3 to the  
point I think this should work, but it doesn't:

I've defined the following extention:

#include <escheme.h>
#include <string.h>

Scheme_Object *scheme_initialize(Scheme_Env *env) {
   Scheme_Env *menv;
   Scheme_Object *proc;
    menv = scheme_primitive_module(scheme_intern_symbol 
("helloworld"), env);

                      scheme_make_integer_value(100), menv);

    return scheme_void;

//  return scheme_make_byte_string("hello world");

Scheme_Object *scheme_reload(Scheme_Env *env) {
   return scheme_initialize(env); /* Nothing special for reload */

Scheme_Object *scheme_module_name() {
   return scheme_false;

and compiled it using

  mzc --cc ++ccf -I/usr/local/plt/include helloworld.c

and linked it thus

  mzc --ld helloworld.dylib ++ldf  -L/usr/local/plt/lib/ helloworld.o

I've defined a module thus:

(module helloworld mzscheme

(load-extension "/Users/pjw/prog/scheme/mzgdbm/helloworld.dylib")


When I require this module somewhere else, I get

/Users/pjw/Library/PLT Scheme/299.106/collects/helloworld/ 
helloworld.ss:1:0: module: provided identifier not defined or  
imported at: helloworld in: (#%plain-module-begin (require-for-syntax  
mzscheme) (load-extension "/Users/pjw/prog/scheme/mzgdb...

indicating that the definition of helloworld in the extension is not  
available to be provided.  I'm sure I've messed up the namespaces  
somehow, but its not clear to me how.



Posted on the users mailing list.