From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 4A9A6BBAF for ; Wed, 2 Jun 2010 14:14:56 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgoDACjoBUyGnQCBkWdsb2JhbACSA4wWFQEBAQEJCwoHEQMfwCCFFgQ X-IronPort-AV: E=Sophos;i="4.53,347,1272837600"; d="scan'208";a="60484523" Received: from shiva.jussieu.fr ([134.157.0.129]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Jun 2010 14:14:56 +0200 Received: from hydrogene.pps.jussieu.fr (hydrogene.pps.jussieu.fr [134.157.168.1]) by shiva.jussieu.fr (8.14.4/jtpda-5.4) with ESMTP id o52CEsKB029347 ; Wed, 2 Jun 2010 14:14:55 +0200 (CEST) X-Ids:164 Received: from [134.157.168.107] (bohrium.pps.jussieu.fr [134.157.168.107]) by hydrogene.pps.jussieu.fr (8.13.4/jtpda-5.4) with ESMTP id o52CErnq025782 ; Wed, 2 Jun 2010 14:14:53 +0200 Subject: Difference between ocamlc and ocamlopt when marshalling reference From: Mathias Kende To: caml-list@inria.fr Content-Type: text/plain Date: Wed, 02 Jun 2010 14:16:39 +0200 Message-Id: <1275480999.5099.19.camel@bohrium.pps.jussieu.fr> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 7bit X-Miltered: at jchkmail.jussieu.fr with ID 4C064B3E.004 by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 4C064B3E.004/134.157.168.1/hydrogene.pps.jussieu.fr/hydrogene.pps.jussieu.fr/ X-Spam: no; 0.00; ocamlc:01 ocamlopt:01 marshalling:01 marshalling:01 ocamlc:01 ocamlopt:01 printf:01 printf:01 cheers:01 mathias:98 mathias:98 closures:01 compilers:01 marshal:01 marshal:01 Hi, I found a difference on the way global references used inside a function are handled with respect to marshalling between ocamlc and ocamlopt. See the exemple below : -------------- a.ml --------------- let r = ref 0 let p () = Printf.printf "%d\n" !r let s = Marshal.to_string p [Marshal.Closures] let () = r := 1 let q : unit -> unit = Marshal.from_string s 0 let () = q () ----------------------------------- $ ocamlc a.ml $ ./a.out 0 $ ocamlopt a.ml $ ./a.out 1 ----------------------------------- I am not sure which semantic is the "good" one. They are both interesting, but having only one is definitely simpler. Is this a known problem ? is there fundamental reasons in the compilers for which it can not be changed ? Cheers, Mathias