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

Re: passing C data to Scheme world

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.

>>>>> "Shiro" == Shiro Kawai <shiro@xxxxxxxx> writes:

Shiro> Regarding "Keeping C data structures in the Scheme heap".

Shiro> Do we limit it to have simple structures that have no
Shiro> pointers to outside resource?  Otherwise we have some
Shiro> issues:

Shiro> - If we want to keep C structures that has pointers,
Shiro>   in Scheme heap, we need a hook to tell GC about it.

The idea is that you either keep those pointers somewhere in the
Scheme world or register them via SCHEME_GC_PROTECT_GLOBAL and manage
them manually.

We punted on this whole issue because (as you noticed) it requires
bringing in a whole bunch of complex machinery.  (See, say, the
Objective Caml FFI for an idea just how complex.)  Moreover, in my
experience, keeping the references in Scheme usually makes a lot of
things easier.

Shiro> - Related to above; if we want to keep C structures that
Shiro>   has handles for extrenal resouces (externally allocated
Shiro>   memory, opened file descriptor, etc.), we need a kind of
Shiro>   finalization mechanism.

That's also something meant to be done in Scheme.

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