guile-user
[Top][All Lists]
Advanced

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

Re: new sqlite binding


From: Andy Wingo
Subject: Re: new sqlite binding
Date: Mon, 29 Nov 2010 21:50:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi,

On Sun 28 Nov 2010 12:51, Neil Jerram <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]