[plt-scheme] Looking up symbol in modules from C

From: Tim Brown (tim.brown at cityc.co.uk)
Date: Thu Jul 8 09:02:11 EDT 2004

Folks,

I think I'm missing something here...

I have a module in "foo.ss" (on my library path):

{
module foo mzscheme
  (provide bar)
  (define (bar) 3/2)
}

And a C program that wants to use bar:

   Scheme_Env* Env = scheme_basic_env();
   Scheme_Object* p_bar;

   scheme_eval_string("(namespace-require '(lib \"foo.ss\"))", Env);
   /* succeeds */

   scheme_eval_string("(printf \"~s~%\" (namespace-mapped-symbols))", Env);
   /* prints amongst others bar */

   p_bar = scheme_eval_string("bar", Env);
   /* assigns p_bar to bar */

   p_bar = scheme_lookup_global(scheme_intern_symbol("bar"));
   /* p_bar is null */

How do I "lookup" the value of bar from the current environment,
without eval_string'ing it?

I may be missing something fundamental here, and my appreciation of what
an "environment", "namespace", "module" and "global" (as well as maybe the
idea of "lookup") are probably not solid. If so, could someone explain
these terms to me.

Thanks

Tim


-- 
Tim Brown <tim.brown at cityc.co.uk> |            City Computing Limited |
T: +44 20 8770 2110               |      City House, Sutton Park Road |
F: +44 20 8770 2130               |       Sutton, Surrey, SM1 2AE, GB |
BEAUTY: What's in your eye when you have a bee in your hand.__________/




Posted on the users mailing list.