[MLton] bool and MLton FFI

skaller skaller@users.sourceforge.net
Fri, 23 Jun 2006 15:35:55 +1000


On Thu, 2006-06-22 at 19:52 -0700, Stephen Weeks wrote:

> So, here are the options.
> 
>   1. No bool in the FFI.
>   2. C Bool in the FFI with manual conversion to/from SML bool.
>   3. Bool in the FFI with automatic conversion between C bool and SML
>      bool. 

This problem is not isolated to C Bool. It also applies to
all C integral types.

You have two choices: 

(a) use exact integers in ML
(b) use C primitives in ML

If you do (a), then C wrapper code is non-portable, but the ML
code is platform independent.

If you do (b), C wrapper code will be portable, but the ML
code semantics will depend on the underlying C compilers
choice of integer sizes.

Neither is ideal, and you can't easily do both.
MLton seems to chose (a), Felix chooses (b).

The issue is not MLton specific. Indeed it applies to
C code itself.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net