[plt-scheme] C extension module

From: Ron Stanonik (stanonik at Cogsci.ucsd.edu)
Date: Sun Feb 8 23:38:43 EST 2004

I've written a C extension which defines a module.  After compiling, I can
load-extension and require the module, but am I overlooking something?
Do I really still need to load-extension?  That is, is there no require
syntax which does the load-extension and avoids any problems that might
occur due to unintentional multiple loads?

stanonik at cogsci.ucsd.edu

   * mzc --cc hello.c
   * mzc --ld hello.so hello.o
   * (load-extension "hello.so")
   * (require hello_mod)
   * (sch_hello)
  #include "escheme.h"
  Scheme_Object *
  sch_hello(int argc, Scheme_Object **argv)
  { return scheme_true; }
  Scheme_Object *scheme_reload(Scheme_Env *env)
    Scheme_Env *mod_env =
      scheme_primitive_module(scheme_intern_symbol("hello_mod"), env);
      scheme_make_prim_w_arity(sch_hello, "sch_hello", 0, 0), mod_env);
    return scheme_make_string("Hello");
  Scheme_Object *scheme_initialize(Scheme_Env *env)
  { return scheme_reload(env); }
  Scheme_Object *scheme_module_name()
  { return scheme_intern_symbol("hello_mod"); }

Posted on the users mailing list.