Re: Couple things... Bradd W. Szonye 09 Jan 2004 18:08 UTC

bear wrote:
> Restricting the manipulation of scheme strings and numbers to handling
> by scheme routines (directed or invoked from C code) would allow much
> better solutions.

I agree that it's generally better to segregate the Scheme and C data,
such that C can't touch the Scheme heap at all. However, for practical
reasons, I think there must be *some* way to communicate between the
two. Personally, I think the safest and most general way to do that is
with handles and conversion functions that duplicate the data.

For example, if C code needs access to a Scheme number, then allow it to
ask for a handle to the number. When it wants the value of that number,
use a handle->int or handle->double function. If C code needs to access
arbitrary Scheme data, use something like handle->malloc that allocates
a copy that C can stomp on all it wants.

Sorry for the vagueness -- I've got a head cold, and it's hard to think
straight. If I understand him correctly, this is similar to the approach
that Tom Lord advocates. Arbitrary C code *can* deal with Scheme data,
but it doesn't actually touch the heap; all of the "heap critical
sections" are in the FFI itself.
Bradd W. Szonye