[plt-scheme] FFI + errno

From: Thomas Chust (chust at web.de)
Date: Mon Dec 21 12:56:53 EST 2009

Eli Barzilay schrieb:
> [...]
> If it's the former, then fixing it would involve changing C code to
> accept some way to store the errno (eg, passing in a box, or a setter
> function), and then changing the `_fun' interface to communicate such
> a receiver.  You might also have efficiency issues, for example, if
> you use a box value, then this means allocating a box for every such
> call.  (Which might as well be negligible wrt the overall glue cost.)
> [...]

Hello,

after reading the source code I think it is easy to modify ffi_do_call
in src/foreign/foreign.ssc to return two Scheme values instead of one on
request: The actual return value of the foreign function and a potential
error code. I see no reason why this would involve rewriting the
interface of the native functions, or the allocation of additional
boxes, unless calling scheme_values does some kind of boxing.

However, the necessary modification of the corresponding Scheme code in
collects/scheme/foreign.ss could well be more complicated than the
current solution. I guess I'm too lazy and insufficiently motivated to
come up with a patch ;-)

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.



Posted on the users mailing list.