caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: "'Jean Krivine'" <jean.krivine@gmail.com>,
	"'caml users'" <caml-list@inria.fr>
Subject: RE: [Caml-list] Marshalling question
Date: Fri, 8 Oct 2010 13:39:57 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D92B751D@Remus.metastack.local> (raw)
In-Reply-To: <AANLkTikE_t9gDF0GojjytXyZwOZCdVy4chLt2xiVc_ge@mail.gmail.com>

Jean Krivine wrote:
> Dear ocaml users,
> 
> A simple question: is it safe to marshalize a data structure that contains
> imperative elements (like arrays or hashtbl) ?

Simple answer: yes. Marshal works on the runtime representation of data which is imperative (immutability is enforced by the type system, not the runtime).

> I found the documentation of the Marshal module rather obscure to me.
> In particular it is not clear whether I should use the No_sharing flag.

Unless you know how the data structures you are marshalling work, you should never use this flag (i.e. if you're working with an abstract data type like Hashtbl.t then you certainly shouldn't be using this flag). The obvious reason is that if the data contain a cycle that you're not aware of then your program will not terminate. Less obvious reasons include structures (e.g. for memoizing) which rely on value sharing so that they can use physical, rather than structural equality for speed. The worst thing that can happen when this flag isn't given is that the operation might be a teensy bit slower than it strictly needs to be.



David 


  reply	other threads:[~2010-10-08 13:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-08 13:37 Jean Krivine
2010-10-08 13:39 ` David Allsopp [this message]
2010-10-08 13:48 ` [Caml-list] " Mathias Kende
2010-10-12  8:42   ` Alexey Rodriguez
2010-10-12  9:25     ` Julien Signoles
2010-10-12  9:26     ` Mathias Kende
2010-10-12  9:42       ` Julien Signoles
2010-10-12  9:48         ` Alexey Rodriguez
2010-10-09  7:58 ` forum

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=E51C5B015DBD1348A1D85763337FB6D92B751D@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    --cc=jean.krivine@gmail.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).