[MLton-user] defunctorization

Jesper Louis Andersen jesper.louis.andersen at gmail.com
Tue May 25 13:32:01 PDT 2010


On Tue, May 25, 2010 at 8:50 PM, Sean McLaughlin <seanmcl at gmail.com> wrote:

> Is there any way to turn that off when I'm debugging, and turn it on again for production compilation?

Matthew will probably correct me if I am wrong: No, there is not. Part
of the lure is that when you strip functors from the program by
expansion, you make it vastly simpler to compile. Together with
monomorphisation, which expands polymorhpic functions into monomorphic
ones, and closure conversion you end up with a first-order monomorphic
language. The backend of the system relies heavily upon the simplicity
gained from these transformations.

If you could choose not to expand functors, then the system would have
to keep track of the parameter to that functor. This in turn
complicates all the phases of the compiler up till the point you
eliminate the parameter by making it explicit (like in CC, where a
higher-order function is turned into a first-order one).

It is striking how much full-program compilation simplifies the
innards of a compiler. This is an excellent example of such a
simplification opportunity.

-- 
J.



More information about the MLton-user mailing list