[plt-scheme] exceptions and extensions

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Apr 6 12:35:44 EDT 2003

At Sat, 5 Apr 2003 18:56:01 -0500, "Pedro Pinto" wrote:
> I am trying to write a mzscheme extension using Microsoft Managed C++ and I
> have come across a problem with exceptions. The following code:
> 
> void t()
> {
>     throw 0;
> }
> 
> Scheme_Object *test(int argc, Scheme_Object **argv)
> {
>     try
>     {
>         t();
>     }
>     catch (...)
>     {
>         scheme_signal_error("uups");
>     }
>     return scheme_void;
> }
> 
> 
> will kill MzScheme the second time test is invoked (the first time it
> displays "uups"). Does anyone have any ideas as to why?

Do you get different results compiling the above code as plain old C++
instead of Managed C++?

I don't know what MC++ might require of the environment. Possibly MC++
doesn't like the way that scheme_signal_error() uses scheme_longjmp()
to escape from test(). If that's the case, you may need to catch all
MzScheme escapes in MC++ code using scheme_setjmp(), and then get out
of MC++ completely before continuing with scheme_longjmp().

Matthew



Posted on the users mailing list.