Hi,

On Sun 28 Nov 2010 12:51, Neil Jerram <n...@ossau.uklinux.net> writes:

> I like the backend-independence of the DBI interface, and I also like
> Scheme code that I can just drop in and use without needing to compile
> any C.

Yes to both! And a good suggestion you had later.

But I would like to mention the downside of the dynamic FFI
approach: with the static FFI you get typechecking by the C
compiler, but with the dynamic FFI you're on your own.

So as you see in these bindings, I declare the types of the C functions
I wrap in the Scheme source code, rather than getting that info from the
C headers. Ludovic has some code to (ab)use the C compiler to at least
get info about struct layout.

I suppose you could also use the C compiler to at least check that the
function type you declared is correct; if you want to do, at runtime,

   (pointer->procedure int (dynamic-func "foo" (dynamic-link)) (list int32))

you could at least make a compile-time check that

    typedef int (*foo_type) (int32 bar);
    int main (...)
    { foo_type bar = foo; return 0; }
    
doesn't produce any warnings with -Wall, or something.

And of course to do those compile-time checks there should be a module
to abstract the various compilers, etc; Ludovic has also said that he's
interested in poking this.

Anyway, just wanted to say that while the dynamic FFI is fun, it's a bit
more amateur than the static FFI.

Happy hacking,

Andy
-- 
http://wingolog.org/

Reply via email to