From: Zheng Li <li@pps.jussieu.fr>
To: caml-list@inria.fr
Subject: Re: The sharing mechanism in the Marshal module
Date: Sun, 04 Mar 2007 15:38:52 +0100 [thread overview]
Message-ID: <87odn9f4zn.fsf@gmail.com> (raw)
In-Reply-To: <45E98D4D.3020200@ropas.snu.ac.kr>
Hi,
Deokhwan Kim <dk@ropas.snu.ac.kr> writes:
> I thought the following code would produce 2 in (* 1 *), but as it is it
> outputs 1:
That's the semantic of marshal, it serialize functional values as *closures*,
i.e. functions carrying its whole environments. In your example, the incr1
also gets a copy of incr's environment, which has a copy of c included.
Despite some flaws being spotted in the marshal module last month [1], as far
as your example goes, you should stick with the closure semantics.
> Why? In addtion, what should I do if I really want the sharing of the c
> counter between incr and incr1?
There are some workarounds, but it depends on why you need marshaling. In
many cases, you don't actually need marshal for a shallow copy.
[1] http://caml.inria.fr/pub/ml-archives/caml-list/2007/02/84333195e90a8f13ac9fea7fb6a706bf.en.html
--
Zheng Li
http://www.pps.jussieu.fr/~li
next prev parent reply other threads:[~2007-03-04 14:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-03 14:59 Deokhwan Kim
2007-03-04 14:38 ` Zheng Li [this message]
2007-03-07 14:59 ` [Caml-list] " Roland Zumkeller
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=87odn9f4zn.fsf@gmail.com \
--to=li@pps.jussieu.fr \
--cc=caml-list@inria.fr \
/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