[plt-scheme] namespaces and C extensions

From: Daniel Silva (dansilva at lynx.dac.neu.edu)
Date: Sat Apr 10 17:59:37 EDT 2004

In the following code,

(module c-bindings mzscheme
  (define (spy-add-cpython-type id tobj)
     ...)

  (load-extension "cpy-bindings.ss")

  ...)

I get this error from within the C code that tries to access
"spy-add-cpython-type":
reference to undefined identifier: spy-add-cpython-type

If I change the module to be

(module c-bindings mzscheme
  (define (spy-add-cpython-type id tobj)
     ...)

  (namespace-set-variable-value! 'spy-add-cpython-type
                                 spy-add-cpython-type)

  (load-extension "cpy-bindings.ss")

  ...)

It sort of works, except the second time I click DrScheme's execute
button.  Then I get this error:

compile: bad syntax; reference to top-level identifiers is not allowed,
because no #%top syntax transformer is bound in: spy-add-cpython-type

I looked through the mzc manual but couldn't find the problem.  How
should I access Scheme code from C?

TIA,
Daniel



Posted on the users mailing list.