Version française
Home     About     Download     Resources     Contact us    
Browse thread
evaluation order
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: vanicat@d...
Subject: Re: evaluation order
Christophe Raffalli <raffalli@univ-savoie.fr> writes:

> 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 ?

Both must follow the specification, but order of evaluation is left
unspecified in ocaml, so this difference is not a bug. The bug is in
your code that depend of an unspecified feature of one of the compiler.
-- 
Rémi Vanicat