[MLton] Re: OpenGL for MLton - slight return

Matthew Fluet fluet@cs.cornell.edu
Tue, 11 Nov 2003 08:41:30 -0500 (EST)


> You may recall we briefly discussed the possibility of extending the FFI
> datatypes so that C floats could be passed as arguments without having to
> use an intermediate C function which had no purpose other than to convert
> SML reals (C doubles) into C floats for certain C functions.

All of that functionality is there in the latest experimental version.
(Although, there isn't a Cygwin binary posted.  Stephen can probably build
you one.)  There is a full Real32 structure that matches the Basis
specification and Real32.real is a valid type for importing and exporting
to C functions.

Note, there are various caveats about using Real32 (and Real64) with
regards to precision.  In particular, as long as values are sitting in an
x86 floating point register, they are maintained at 80bit precision, so
the results are not necessarily the same as if the values were maintained
at 32 or 64bit precision.  It's probably only a problem for numerical
guys.

Since the last release, the
 _ffi "name": ty -> ty;
syntax has changed to
 _import [cdecl|stdcall] "name": ty -> ty;

-Matthew