[MLton] bool and MLton FFI
Sat, 24 Jun 2006 13:54:39 +1000
On Fri, 2006-06-23 at 16:58 +0200, Wesley W. Terpstra wrote:
> There is some typedef for GLint; obviously, that's what you would use.
> ie: map 'typedef int GLint' to 'type GLint = C_Int.int'
Yup, that satisfies the requirement.
> > #if _WIN32
> > #type GLint = int
> > #endif
> I'm going to assume by the above you mean something like:
> #ifdef X
> typedef int GLint;
> typedef long GLint;
I mean conditional compilation of ML code reflecting the C code.
So if you have the above C code you wrote, then you need something
type GLint = C_Int.int;
type GLint = C_Long.long
in the ML code, in order that the ML code be portable.
Using an FFI generator parsing the C of course can get around this,
but in general such generators don't work well enough,
and certainly don't produce portable interfaces,
at least without hinting. A generator with hints is a good
solution IF it can be made to work well enough.
A better solution is a generator written in Perl or
Python for just that library .. for example the FFI
could be embedded in an interscript document (interscript
is my Python hosted literate programming tool, which has
extensive text generation ability because it's a superset
However a suitable *in language* solution is much easier
to use provided it has enough semantic power.
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net