caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Mark Shinwell <Mark.Shinwell@cl.cam.ac.uk>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Marshal.to_string and mutable values
Date: Thu, 15 Sep 2005 17:55:24 +0100	[thread overview]
Message-ID: <20050915165524.GH5470@three-tuns.net> (raw)
In-Reply-To: <200509151654.46707.jon@ffconsultancy.com>

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.


      reply	other threads:[~2005-09-15 16:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-15 14:45 Frédéric Gava
2005-09-15 15:13 ` [Caml-list] " Ingo Bormuth
2005-09-15 15:49   ` Frédéric Gava
2005-09-15 15:54     ` Jon Harrop
2005-09-15 16:55       ` Mark Shinwell [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050915165524.GH5470@three-tuns.net \
    --to=mark.shinwell@cl.cam.ac.uk \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).