[MLton] adding synchronous finalizers

Henry Cejtin henry@sourcelight.com
Fri, 1 Oct 2004 14:41:46 -0500


I'm  ok  for now with only finalizers being handled.  Probably the Gtk people
should speak up if it is a problem for their use.

From my understanding of your code (and my knowledge of  the  MLton  run-time
system  is  VERY weak with regards to any of the multi-threaded stuff), won't
it pay attention to the flag only when an object is added to the finalization
world?   That  certainly isn't what I would have expected: I would think that
setting  Finalizable.finalizeSynchronously  to  true  would  mean   that   no
finalizers would be called (except via Finalizable.runFinalizers) until I set
it to false.  Also, when I set it to false I  would  expect  all  finalizers,
even ones made finalizable while it was true, to then run automatically.

I  think  that it is important to realize that there are two distinct reasons
(well, at least two) for including things in MLton instead of  having  people
implement  them  themselves: one is that you can't implement it unless you go
into the run-time system.  Another one, and I think the one that is important
here,  is  when  it  is  important  that  all  uses of a facility use it in a
compatible way.  I.e., if I want  to  run  some  code  with  only  synchronus
finalization,  I  want  that  to be the case even for finalization of objects
that I have nothing to do with creating.  That seems to  require  a  program-
wide agreement, and so argues strongly to put it in MLton.  Finalizable