[MLton-user] SML unicode support

Stephen Weeks MLton-user@mlton.org
Fri, 7 Jan 2005 11:34:52 -0800


> > 	-char-width {8,16,32}
> >
> > This is a lot of work to implement, but would be very nice to have.
> > It's also similar to other flags we've been thinking about to specify
> > the width of the primitive integer, real, and word types.
>
> I would love to be able to do this, as well as make Int be IntInf.
> (Unfortunately there are some ramifications for FFI in both cases.)

I assume what you're referring to is the fact that SML's int would not
necessarily be the same as C's int.  A similar problem comes up as we
port to new platforms, because the natural size of int changes from
platform to platform.

The solution we've come up with is to decouple the SML types (int,
real, word, ...) from C types and create a new structure defining C
types.

signature C_TYPE =
   sig
      type char
      type double
      type float
      type int
      type signedChar
      type signedInt
      type unsignedChar
      type unsignedInt
      ...
   end

Then, if one wants to use the FFI in a way that is portable across
platforms as well as across flags changing default widths, one must
use the CType types.  For backwards compatibility, we will still allow
programs to use the FFI to use int, real, word, etc.

We have to solve this problem for our basis library implementation
anyway, so we will make whatever solution we come up with available to
user programs as well.  Of course, we're interested to hear any ideas
others have for solving this problem.