Version française
Home     About     Download     Resources     Contact us    
Browse thread
Marshal.to_string and mutable values
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Marshal.to_string and mutable values
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.

> Why is 
> it not possible to load a special Marshal module for the toplevel ? I would
> be nice to have your program (in my case, parallel programs) that works
> in the toplevel (for debugging) and as compiled programs.

Yes. INRIA have put a lot of effort into making ocaml, ocamlc and ocamlopt as 
compatible as possible. However, there are still discrepancies. Floating 
point arithmetic is another one.

> To debug a program, I used many times the toplevel. And in my case, I need
> to  serialized functions. In the compiled program, it works but not in the
> toplevel. But before have a program which works
> I need the toplevel...paradox....

Can you get rid of the closures in your Marshalled value? Failing that, maybe 
metaocaml could work - you might be able to marshal "code" values instead of 
closures.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists