From: Andy Wingo <wingo@pobox.com>
To: Neil Jerram <neil@ossau.uklinux.net>
Cc: guile-user <guile-user@gnu.org>
Subject: Re: new sqlite binding
Date: Mon, 29 Nov 2010 21:50:29 +0100 [thread overview]
Message-ID: <m34oazzwfe.fsf@unquote.localdomain> (raw)
In-Reply-To: <87r5e51u4n.fsf@ossau.uklinux.net> (Neil Jerram's message of "Sun, 28 Nov 2010 11:51:58 +0000")
Hi,
On Sun 28 Nov 2010 12:51, Neil Jerram <neil@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/
next prev parent reply other threads:[~2010-11-29 20:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-25 14:12 new sqlite binding Andy Wingo
2010-11-27 6:20 ` Linas Vepstas
2010-11-28 11:51 ` Neil Jerram
2010-11-28 16:08 ` Linas Vepstas
2010-11-29 21:11 ` Andy Wingo
2010-11-29 20:50 ` Andy Wingo [this message]
2010-12-03 18:35 ` Neil Jerram
2010-12-07 4:46 ` Linas Vepstas
2010-12-07 9:50 ` Neil Jerram
2010-11-29 20:43 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m34oazzwfe.fsf@unquote.localdomain \
--to=wingo@pobox.com \
--cc=guile-user@gnu.org \
--cc=neil@ossau.uklinux.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).