[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Couple things...

This page is part of the web mail archives of SRFI 50 from before July 7th, 2015. The new archives for SRFI 50 contain all messages, not just those from before July 7th, 2015.

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