[MLton] def-use mode suggestions

Tom 7 twm at andrew.cmu.edu
Tue Feb 20 15:33:11 PST 2007


> Do you mean to load or to parse?  The latest def-use mode can query
> information from a def-use file loaded into a buffer without having to
> perform complete parsing:

Ah, perhaps I was not using the newest version. I will try it!
I guess I also prefer to suppress the highlighting for symbols like ^ 
(especially the highlighting of the other uses in the buffer) but perhaps 
I could solve this better with a blacklist in du-mode.

> I also think that it would make sense to write def-use info even if
> elaboration fails.  Could you send your patch to the list.  Someone
> could then take a look at it.  I'm afraid I'm not that intimitely
> familiar with everything that processDefUse does either.

The (trivial) patch is attached. processDefUse is clearly effectful, but 
the distance that the code moves is not very high.

> the project.  Works quite nicely.  Most of the time the new def-use
> info just gets reloaded automatically.  I've been thinking about writing
> some minimal Emacs support for working like this (e.g automatically
> rerun compile command after some buffers have been saved, get output
> (errors) from the compiler into a buffer, ability to jump to errors).

Yeah, this would be great. At least for my projects, mlton is a little bit 
resource intensive to get "live" continuous updates. I know mlton is 
necessarily whole-program for its backend, but is it crazy to think that 
the frontend could be incremental?

  Tom
-------------- next part --------------
Index: compile.fun
===================================================================
--- compile.fun	(revision 5279)
+++ compile.fun	(working copy)
@@ -367,7 +367,11 @@
     style = Control.ML,
     thunk = (fn () =>
              (Const.lookup := lookupConstant
-              ; elaborateMLB (lexAndParseMLB input, {addPrim = addPrim}))),
+              ; let val (E, decs) = elaborateMLB (lexAndParseMLB input, {addPrim = addPrim})
+                in (* process here so that we write out def-use info even if elaboration fails - tom7 *) 
+                   Env.processDefUse E;
+                   (E, decs)
+                end)),
     display = displayEnvDecs}
 
 (* ------------------------------------------------- *)
@@ -403,7 +407,7 @@
                File.withOut
                (f, fn out =>
                 Layout.outputl (Env.layoutCurrentScope E, out))
-      val _ = Env.processDefUse E
+      (* val _ = Env.processDefUse E *) (* above -tom7 *)
       val _ =
          case !Control.exportHeader of
             NONE => ()


More information about the MLton mailing list