From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 6758FBC69 for ; Sun, 4 Mar 2007 15:38:34 +0100 (CET) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l24EcXfu027402 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sun, 4 Mar 2007 15:38:34 +0100 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1HNrqk-0000QK-03 for caml-list@inria.fr; Sun, 04 Mar 2007 15:38:10 +0100 Received: from hydrogene.pps.jussieu.fr ([134.157.168.1]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 04 Mar 2007 15:38:09 +0100 Received: from li by hydrogene.pps.jussieu.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 04 Mar 2007 15:38:09 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Zheng Li Subject: Re: The sharing mechanism in the Marshal module Date: Sun, 04 Mar 2007 15:38:52 +0100 Message-ID: <87odn9f4zn.fsf@gmail.com> References: <45E98D4D.3020200@ropas.snu.ac.kr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: hydrogene.pps.jussieu.fr User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux) Cancel-Lock: sha1:qiWhNFXCGJz1pbkJsmKcqfcALyY= Sender: news X-Miltered: at discorde with ID 45EAD9E9.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; serialize:01 semantics:01 workarounds:01 marshaling:01 closures:01 caml-list:01 writes:01 functions:01 pps:01 pps:01 marshal:01 marshal:01 jussieu:01 jussieu:01 closure:01 Hi, Deokhwan Kim 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