[plt-scheme] Code for catching exceptions in embedding applications

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Nov 6 13:05:42 EST 2008

At Thu, 6 Nov 2008 18:12:10 +0300, "Sergey Khorev" wrote:
> Great thanks and now, I hope, the last question in the series: I
> cannot find `exn?' and `exn-message' in the basic environment, i.e.
> scheme_lookup_global(scheme_intern_symbol("exn?"), environment)
> returns NULL.
> 
> I tried to `require' scheme instead of scheme/base but this did not help.
> 
> Can you advise what is required for code to work.
> 
>     environment = scheme_basic_env();
>     declare_modules(environment);
>     scheme_namespace_require(scheme_intern_symbol("scheme/base"));
>     exn_p = scheme_lookup_global(scheme_intern_symbol("exn?"), environment);

When you `require' a module, it doesn't create top-level variables ---
only import bindings. The scheme_lookup_global() function looks only
for top-level variables, ignoring bindings.

You could use eval. In this case, though, just use
scheme_builtin_value():

    exn_p = scheme_builtin_value("exn?");


Matthew



Posted on the users mailing list.