[plt-dev] fixing mzscheme/examples

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Sat Nov 14 14:13:26 EST 2009

I tried to fixup the examples in collects/mzscheme/examples but ran into 
some issues.

If I compile catch.c into catch.so and run it with this code

(load-extension "catch.so")
(printf "~a\n" (eval-string/catch-error "(+ 1 'a)"))

$ mzscheme -f x.ss

Then I get:
#f::0: compile: unbound identifier (and no #%app syntax transformer is 
bound) at: lambda in: (lambda (thunk) (with-handlers ((void (lambda 
(exn) (cons #f exn)))) (cons #t (thunk))))

Which usually means scheme/base hasn't been require'd. Putting (require 
scheme/base) into x.ss doesn't help so I tried modifying the C code. 
Probably the environment in `init_exn_catching_apply' has to be modified 
but the only way I can see to modify namespaces is with 
scheme_namespace_require. So I put `env' into the current MZCONFIG_ENV 
param and called 
scheme_namespace_require(scheme_intern_symbol("scheme/base")) but when I 
load the resulting .so I get an infinite loop.

Is `scheme_make_namespace' the wrong function to call to get a new 

Also, not a big deal, but this command
  mzc --3m --cc catch.3m.c

produces catch_3m.c instead of catch.c. The docs say it would produce 

Posted on the dev mailing list.