[MLton] Parsing bug?

Matthew Fluet fluet@cs.cornell.edu
Mon, 6 Dec 2004 09:29:51 -0500 (EST)

> SML/NJ and MLton should give the same output for an SML 97 program running
> over the same input, right?

Technically, yes; realistically, no.

Technically, SML'97 as defined in _The Definition of Standard ML_ requires
only a a minimal initial basis, which, while including the types "int",
"real", "char", and "string", need have no operations on those base types.
Hence, the only observable output of an SML'97 program is termination or
raising an exception.  SML/NJ and MLton should agree there, to the degree
each agrees with _The Definition_. (See http://mlton.org/UnresolvedBugs
for MLton's very few corner cases.)

Realistically, a program needs to make use of the Standard Basis Library.
Within the Basis Library, there are numerous places where the behavior is
implementation dependent.  For a trivial example:
  val _ = valOf (Int.maxInt)
may either raise the Option exception (if Int.maxInt == NONE) or may
terminate normally.  The default Int/Real/Word sizes are the biggest
implementation dependent aspect; so, one implementation may raise Overflow
while another can accomodate the result.  Also, maximum array and vector
lengths are implementation dependent.  Interfacing with the operating
system is a bit murky, and I'm sure implementations differ in handling of
errors there.

That said, your program doesn't clearly fall into one of these cases, and
it certainly isn't behaving as I would expect.