[MLton] Re: [Smlnj-dev-list] Evolving SML

John Reppy jhr@cs.uchicago.edu
Tue, 25 Oct 2005 23:13:01 -0500


On Oct 25, 2005, at 10:39 PM, Robert Harper wrote:

> 3. the current treatment of numerics is terrible and should be  
> fixed.  morrisett has recently advocated making int be arbitrary  
> precision integer arithmetic, and have separate finite "integer"  
> types for special purposes that really want them and care about  
> them.  what do people think about this?  remember, it's entirely a  
> question of the defaults, because we can obviously have libraries  
> for both arbitrary precision and bounded precision numbers, signed  
> and unsigned, whatever you like.

The current treatment of numerics was forced on us by the desire to  
be compatible with a range of
different implementations (i.e., SML/NJ had 31-bit ints, MLWorks had  
30-bit (I think), etc.).
It was a mistake.  We should have specified specific sizes.  In Moby,  
we've gone with three types:
Int (32-bit, 2's complement), Long (64-bit, 2's complement), and  
Integer (arbitrary precision),
which works reasonably well.  BTW, one argument for specifying 32-  
and 64-bit types is that you need them
to make foreign interfaces work well.

Making arbitrary precision integers the default type may be a  
significant performance hit (I'm thinking
about operations like array indexing), so I would want to understand  
the impact before making that
switch.

The most important thing is consistency across implementations.

     - John