calling SML from C

Stephen Weeks MLton@sourcelight.com
Mon, 20 Aug 2001 14:51:09 -0700


> As a related point, when we were working on our Java compiler, we faced a
> similar issue.  We were able to hack up a solution that did not involve
> forking
> multiple Java threads.  Instead, we implemented special Java stubs that
> handled
> returns back from C and allowed us to reuse the Java stack when C called a 
> Java function.

Definitely worth considering.

> The implementation also handled exceptions that were raised
> by
> a Java procedure whose handler was another Java procedure that sat below a 
> C call(s).

Yowsa.  I hadn't considered that, but I don't see how it can work since there is
(conceptually) intervening stuff on the C stack.  My thought was to fail with
error if a call to SML raises an exception, on the thought that the programmer
should have thought of this, handled the exception, and returned some
appropriate error value to C.

> I'll lookup the implementation tonight and describe the stubs we
> used
> if you guys are interested.

Sure.