[
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: | -- (:) |
| From: | Jon Harrop <jon@f...> |
| Subject: | Re: [Caml-list] evaluation order |
On Sunday 14 June 2009 17:36:39 Christophe Raffalli wrote: > Hello, > > In OCaml-3.11.1 (I did not try other version), > the following code print 0 when compiled in bytecode and 1 in nativecode > for obvious reason of different evaluation order in the pair ... > > > let ptr = ref 0 > let fn b = > if b then incr ptr else decr ptr > let c = fn true, !ptr > let _ = print_int (snd c); print_newline () > > Is any difference between ocamlc and ocamlopt a bug ? Not at all, no. They are expected to have different behaviour with respect to floating point arithmetic. In this case, they have chosen to evaluate subexpressions in a different order, which is fine because the order of evaluation is officially undefined. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e