[MLton-devel] pointers and MLton/SMLNJ

Stephen Weeks MLton@mlton.org
Thu, 7 Nov 2002 13:38:34 -0800


> >MLton.eq can be used on any type, including function types, and yes,
> >it will compare the pointers to (MLton's notion of) closures.
> 
> Alright!

Whoops.  That feature hasn't been tested too well.  There is a bug in
the following simple program, which causes MLton to raise an internal
error during compilation.

fun f x = x + 1
fun g x = x + 2
val _  =
   if MLton.eq (f, g)
      then print "yes\n"
   else print "no\n"

I just checked in a fix to our CVS.  The only affected file is
mlton/closure-convert/closure-convert.fun.  So, you can either grab
that and rebuild MLton, or build from the whole CVS tree.

Alternatively, you can prefix your program with the following.

structure MLton =
   struct
      open MLton

      val eq =
	 fn (a, a') =>
	 let
	    val r = ref a
	    val _ = r := a'
	    val r' = ref a'
	    val _ = r' := a
	 in
	    eq (!r, !r')
	 end
   end

This will introduce a loss of precision into MLton's flow analysis
that will keep the bug from happening.


-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel