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=0.5 required=5.0 tests=DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 6DD28BC0A for ; Sat, 3 Mar 2007 15:59:31 +0100 (CET) Received: from ropas.snu.ac.kr (ropas.snu.ac.kr [147.46.242.52]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l23ExUKk002609 for ; Sat, 3 Mar 2007 15:59:30 +0100 Received: from [192.168.11.4] (unknown [220.70.44.76]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ropas.snu.ac.kr (Postfix) with ESMTP id 0F19BEAAFD for ; Sat, 3 Mar 2007 23:59:29 +0900 (KST) Message-ID: <45E98D4D.3020200@ropas.snu.ac.kr> Date: Sat, 03 Mar 2007 23:59:25 +0900 From: Deokhwan Kim User-Agent: Debian Thunderbird 1.0.2 (X11/20070113) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: The sharing mechanism in the Marshal module Content-Type: text/plain; charset=EUC-KR Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 45E98D52.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; printf:01 printf:01 closures:01 marshal:01 marshal:01 int:01 string:02 string:02 module:03 unit:03 let:03 let:03 outputs:04 incr:06 incr:06 Hello, I thought the following code would produce 2 in (* 1 *), but as it is it outputs 1: let incr = let c = ref 0 in function () -> c:= !c + 1 ; !c let save = Marshal.to_string incr [Marshal.Closures] let incr1 = (Marshal.from_string save 0 : unit -> int) let () = Printf.printf "%d\n" (incr ()) ; Printf.printf "%d\n" (incr1 ()) (* 1 *) Why? In addtion, what should I do if I really want the sharing of the c counter between incr and incr1? Thanks.