Email list hosting service & mailing list manager

Re: Pika-style from first principles Michael Sperber 10 Jan 2004 16:00 UTC

>>>>> "Marc" == Marc Feeley <xxxxxx@IRO.UMontreal.CA> writes:

>> So what do you do when there isn't a predefined conversion function
>> between Scheme type and C type?

Marc> You write it in C.  I'm not sure what you are getting at here...

I'm getting at the fact that writing it in C requires access to the C
and Scheme representations from a single piece of code.  Moreover, if
C->Scheme conversion yields a Scheme heap value, then

1. either the C code neads to be able to heap-allocate, or the Scheme
   code heap-allocates, roughly implying that the size of the
   generated object needs to be known before the C code is entered.

2. or the C code needs to be able to heap-allocate, dragging in all
   the issues that this style of FFI supposedly avoids.

Now 1. is feasible---scsh did this up until the 0.5 series, but it's
very, very painful.

(Of course, there's a 3rd alternative, namely Matthias Blume's NLFFI
for SML/NJ, doing everything in the "other language" instead of in C.
But that requires a lot more machinery to be useful and doesn't avoid
using (generated) C code for data access and function argument vector

Another way to look at it is that *this* SRFI is exactly about writing
those conversion functions.  (Or, to put it in Richard's words, "this
SRFI is not that SRFI.")

Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla