[plt-scheme] scheme_primitive_module

From: wayne at taxupdate.com (wayne at taxupdate.com)
Date: Tue Jan 3 07:44:11 EST 2006

I'd like to access a foreign function within a scheme module, so here's the
attempt (using mzscheme v300):

#include "scheme.h"
#include <stdio.h>

Scheme_Object * func(int argc, Scheme_Object **args){
  printf("called func");
  return scheme_void;

int main(int argc, char ** args)
   Scheme_Env * env = scheme_basic_env();

   // add func to a new module "foreign":
   Scheme_Env * mod = scheme_primitive_module(scheme_intern_symbol("foreign"), env);
		     scheme_make_prim_w_arity(func, "func", 0, 0), mod);

   // test:
   char buf[] = "(module test mzscheme "
     "(require foreign)"
     "(require test)";
   scheme_eval_string(buf, env);
   return 0;

Everything compiles and runs, but "func" never gets called.  Am I on the right


Posted on the users mailing list.