caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Difference between ocamlc and ocamlopt when marshalling reference
@ 2010-06-02 12:16 Mathias Kende
  2010-06-02 16:40 ` [Caml-list] " Fabrice Le Fessant
  0 siblings, 1 reply; 2+ messages in thread
From: Mathias Kende @ 2010-06-02 12:16 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-02 16:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-02 12:16 Difference between ocamlc and ocamlopt when marshalling reference Mathias Kende
2010-06-02 16:40 ` [Caml-list] " Fabrice Le Fessant

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).