MLton / mlton

The MLton repository
http://mlton.org
Other
962 stars 127 forks source link

Provide an SML implementation of the IntInf_* primitives #60

Open MatthewFluet opened 10 years ago

MatthewFluet commented 10 years ago

Resolving issue #59 would eliminate the dependency on GMP for compiled programs that do not use structure IntInf. However, there may be programs that use structure IntInf in a non-performance critical way or that indirectly use structure IntInf (e.g., by using structure Time, where time values are implemented using IntInf.int), but would like to avoid the dependency on GMP.

It should be possible to provide an alternative implementation of the IntInf_* primitives in SML. Then use a command line flag -int-inf-impl {gmp,sml} (similar in spirit to the -default-type type flag) which would (among other effects) define an MLB path variable (again, similar to what is done with the -default-type type flag) that would be used to select an appropriate implementation of the IntInf_* primitives for use in the rest of the Basis Library.

It would clearly be less performant than the GMP implementation, but it would probably suffice for many applications where structure IntInf was used, but not used extensively.

robsimmons commented 10 years ago

This seems pretty straightforward, I'd really like to see #59 resolved, and so I'd be interested in trying to attack this over the next couple days if noone else has already started.

MatthewFluet commented 10 years ago

Agreed that this should be pretty straightforward. Feel free to work on it.

You might consider implementing/replacing either:

The advantage of the former is that it is a smaller interface. The disadvantage of the former is that it occurs very early in the Basis Library implementation, and you will have little more than the primitive arithmetic and vector/array functions available.

The advantage of the latter is that it occurs much later in the Basis Library implementation and you will have many more arithmetic and vector/array functions available. The disadvantage is that it is a larger interface.

robsimmons commented 10 years ago

Here's a small oddity - the first line of https://github.com/MLton/mlton/blob/master/basis-library/integer/int-inf0.sml is clearly a typo, since it cuts off Suresh Jagannathan's name. This was introduced in dcb42e5975, presumably this should correctly say 2013 Matthew Fluet?

MatthewFluet commented 10 years ago

Yes, looks like it should be 2013 Matthew Fluet.