[MLton] improved overloading for SML

skaller skaller@users.sourceforge.net
Mon, 17 Oct 2005 22:40:46 +1000


On Mon, 2005-10-17 at 11:40 +0300, Vesa Karvonen wrote:

> 
> Would it be possible to give MLton an interface (an extension) that would
> allow you to query information related to optimizations? Instead of manually
> checking the ILs one would just, for example, ask MLton whether a certain
> piece of code is present in the final output or whether a certain function
> was instantiated with a certain type.

There are three issues here:

(1) Add marker constructions to the grammar.

(2) Make the marks follow the code through the
optimisation process.

(3) Check at various places for a command line
switch enabling marker diagnostics, and also if
we have some marked code.

Now doing (2) from scratch would be insanely difficult
and out of the question for the minor advantage it would
provide -- it involves complexifying every rewrite rule
in the whole compiler!

Luckily all good compilers have ALREADY got a fully
functional tracing facility -- all that extremely
difficult work has already been done.

To issue a sensible diagnostics, the *source reference*
(line numbers in the text files) is already flowed 
through all the rewrite rules, so it should a simple
matter to enhance the source code reference type to accept
a list of string tags.

This leaves propagating the marker constructions in the
grammar into the AST (1), and writing the conditional
diagnostic routines (3) (and command line option handler).
The former is boring but should be easy. The latter
is just a lot of work to finish, which would normally be 
done on a 'needs' basis.

So actually, it looks feasible to me.
But I have no idea if it would be worth the effort,
since it would not be use that often, and likely when
it was needed it wouldn't do the job you wanted anyhow.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net