Browse thread
Marshal.to_string and mutable values
-
Frédéric_Gava
-
Ingo Bormuth
-
Frédéric_Gava
-
Jon Harrop
- Mark Shinwell
-
Jon Harrop
-
Frédéric_Gava
-
Ingo Bormuth
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-09-15 (16:55) |
From: | Mark Shinwell <Mark.Shinwell@c...> |
Subject: | Re: [Caml-list] Marshal.to_string and mutable values |
On Thu, Sep 15, 2005 at 04:54:46PM +0100, Jon Harrop wrote: > On Thursday 15 September 2005 16:49, Fr?d?ric Gava wrote: > > ok. Excuse me for this stupid question (but the error messages are not > > clear). My true question is: why does it not work in the toplevel ? > > Marshal probably marshals the environment of a closure with a pointer to the > position of the code (the code itself is not available to Marshal). Clearly, > that pointer only makes sense in a compiled program and not in the top-level, > e.g. when loading your marshalled value from a fresh top-level, your function > does not exist. It is indeed a problem relating to a disparity between the toplevel and the compiled versions, but the failure is not for the above reason. I encountered the same problem, albeit from a different angle[*], during the implementation of Fresh O'Caml some months ago. At that time I asked Damien Doligez about it and he said: "When the toplevel compiles code on the fly, the resulting code is not recognized as such by the Marshal module, but the code pointers in the closures are seen as generic out-of-heap pointers, and trigger the Invalid_argument exception." Even so, I still don't fully understand why this is the case (perhaps someone could elaborate? ;) Mark [*] Traversing arbitrary values at runtime.