caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Mathias Kende <mathias.kende@ens.fr>
To: caml-list@inria.fr
Subject: Difference between ocamlc and ocamlopt when marshalling reference
Date: Wed, 02 Jun 2010 14:16:39 +0200	[thread overview]
Message-ID: <1275480999.5099.19.camel@bohrium.pps.jussieu.fr> (raw)

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


             reply	other threads:[~2010-06-02 12:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-02 12:16 Mathias Kende [this message]
2010-06-02 16:40 ` [Caml-list] " Fabrice Le Fessant

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=1275480999.5099.19.camel@bohrium.pps.jussieu.fr \
    --to=mathias.kende@ens.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;
as well as URLs for NNTP newsgroup(s).