[MLton-user] MLton.Finalizable.touch
Florian Weimer
fw@deneb.enyo.de
Sat, 27 Aug 2005 09:49:53 +0200
* Stephen Weeks:
> True, it isn't. Unfortunately, the code you sent was syntactically
> incorrect. Could you please send a corrected version? Thanks.
Oops, copied the wrong file. Sorry.
fun test6 (str : string) =
let open MLton.Finalizable
val x = new str
exception Exit
in addFinalizer (x, fn s => print (s ^ ": finalizer\n"));
withValue (x, fn s =>
(print "before GC 6\n";
MLton.GC.collect ();
print "after GC 6\n";
raise Exit))
handle Exit => ()
end
val _ = (print "before test 6\n";
test6 "test 6";
print "before GC 6a\n";
MLton.GC.collect ();
print "after GC 6a\n")
The expected output is:
before test 6
before GC 6
after GC 6
before GC 6a
test 6: finalizer
after GC 6a