[MLton] improved overloading for SML
Stephen Weeks
MLton@mlton.org
Sun, 16 Oct 2005 21:26:09 -0700
> > Furthermore, the signature constraint ensures that
> > clients maintain this invariant.
>
> type 'a t (* 'a is int or real *)
>
> I see a comment, not a constraint?
Correct. That comment doesn't enforce anything. The invariant
follows from what is in the implementation and the fact that the
opaque signature constraint allows the operations to be used only in
certain ways.
> Apart from the use here, what was the original purpose of useless
> variant elimination? I see an advantage in reducing a sum to one
> variant (eliminates the tag entirely). Any other?
That's the main one. There are also benefits to eliminating variants
even when they're is more than one remaining, since more compact
representations can sometimes be chosen for the remaining ones.
Dead-code elimination is another reason -- by eliminating useless
variants one eliminates dead code in unreachable cases. This can then
allow other optimizations to do more.