[MLton] release and future devel

Matthew Fluet fluet at tti-c.org
Thu Jun 11 15:13:02 PDT 2009


On Thu, 11 Jun 2009, Henry Cejtin wrote:
> Oh happy days!!!
>
> Would  it  be easy to have a version of the compiler for AMD64 (or any 64-bit
> architecture I guess) where Int is Int64?  In particular, where I could  have
> arrays and vectors with more than 2 billion elements?

You already have this with mlton-20070826, using '-default-type int64' or 
'-default-type intinf':

[fluet at shadow tmp]$ cat z.sml
fun doit (n: int) : unit =
    let
       val v = Vector.tabulate (n, Word8.fromInt)
       val sum =
          Vector.foldr Word8.+ 0wx0 v
    in
       (print o concat)
       ["n = ", Int.toString n, "; sum = ", Word8.toString sum, "\n"]
    end

val n = Int32.toInt (valOf (Int32.maxInt))
val () = doit n
val () = doit (n + 1)
val () = doit (n + n)

[fluet at shadow tmp]$ ~/devel/mlton/mlton-20070826/build/bin/mlton z.sml
[fluet at shadow tmp]$ ./z
n = 2147483647; sum = 1
unhandled exception: Overflow
[fluet at shadow tmp]$ ~/devel/mlton/mlton-20070826/build/bin/mlton -default-type int64 z.sml
[fluet at shadow tmp]$ ./z
n = 2147483647; sum = 1
n = 2147483648; sum = 0
n = 4294967294; sum = 3
[fluet at shadow tmp]$ ~/devel/mlton/mlton-20070826/build/bin/mlton -default-type intinf z.sml
[fluet at shadow tmp]$ ./z
n = 2147483647; sum = 1
n = 2147483648; sum = 0
n = 4294967294; sum = 3

On a 64-bit platform, all array/vector sub/update operations are with 
64-bit indices.  The Basis Library just wraps them with coercions to/from 
the default Int type.



More information about the MLton mailing list