[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-03-03 (14:59) |
From: | Deokhwan Kim <dk@r...> |
Subject: | The sharing mechanism in the Marshal module |
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.