English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2005-09-15 (16:39)
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 

Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists