[plt-scheme] Using symbols, introduced with namespace-attach-module, in an embedding application

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Dec 15 08:53:23 EST 2003

At Mon, 15 Dec 2003 11:44:35 +0300, Khorev Sergey wrote:
>     scheme_eval_string("(namespace-attach-module basic 'mymod)", ns);
>     if (SCHEME_TRUEP(scheme_eval_string("(memq 'prim1
> (namespace-mapped-symbols))", ns)))
> 	printf("Symbol prim1 in namespace ns is defined\n");

The problem is that scheme_eval_string() is confusing, and the docs are
wrong (or at least very misleading).

The various scheme_eval() functions take an environment that is used to
compile and "link" the Scheme expression, but they do not set the
`current-namespace' parameter while evaluating the expression.

The current namespace in your program is always `basic'. As a result,
`namespace-attach-module' actually attaches `mymod' to basic (which is
a no-op), and `(namespace-mapped-symbols)' above actually returns the
list of mapped symbols in `basic'.

I'll work on the docs. Meanwhile, you might avoid problems by
explicitly setting the namespace to the one where you want to evaluate


Posted on the users mailing list.