serialization and globalization

Stephen Weeks sweeks@wasabi.epr.com
Sun, 15 Aug 1999 03:12:07 -0700 (PDT)


I just ran into an annoying feature (I'm not sure if it's a bug) of
MLton that is caused by the combination of serialization and
globalization.  I have a program where I am saving some state in a
file, and reloading it from the file when the program is run again.
The state happens to be represented as a closure, and that closure
happens to be closed over a ref cell r.  MLton proves that r can only
be created once, and hence globalizes it, removes it from the closure,
and changes all references to the global.

Unfortunately, when I run the program a second time and load the
closure from the file and deserialize it, the ref cell that got
squirreled away does me no good, since the code for the closure is
referring to the global that was initialized when I reran the
program.

In general, then, it seems that I can't depend on serialization of
closures.

Any opinions on whether this is a bug?  If so, any proposals for a
fix?