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

Re: Pika-style from first principles

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.



>>>>> "Marc" == Marc Feeley <feeley@xxxxxxxxxxxxxxxx> 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
assembly.)

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