caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <raffalli@univ-savoie.fr>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] evaluation order
Date: Sun, 14 Jun 2009 23:12:22 +0200	[thread overview]
Message-ID: <4A3567B6.4030002@univ-savoie.fr> (raw)
In-Reply-To: <200906142040.47645.jon@ffconsultancy.com>

Jon Harrop a écrit :
> 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.
>
>   
Despite the fact that it should not be written in OCaml because the 
result rely on the unspecified evaluation order, my example still seems 
to contradict chapter 11 of OCaml's documentation:

"Compatibility with the bytecode compiler is extremely high: the same 
source code should run identically when compiled with ocamlc and ocamlopt."

This kind of bug could also be a nightmare to debug ... because the 
debugger is only available for bytecode ...

Cheers,
Christophe


  reply	other threads:[~2009-06-14 21:08 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-14 16:36 Christophe Raffalli
2009-06-14 17:45 ` Rémi Vanicat
2009-06-14 19:40 ` [Caml-list] " Jon Harrop
2009-06-14 21:12   ` Christophe Raffalli [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-06-15 17:00 [Caml-list] Evaluation Order Manuel Fahndrich
2001-06-10 17:59 Damien Doligez
2001-06-10 18:28 ` Dave Mason
2001-06-10  2:44 David McClain
2001-06-10  2:48 ` Patrick M Doane
2001-06-10  5:51   ` David McClain
2001-06-09 15:59 David McClain
2001-06-09 20:17 ` Brian Rogoff
2001-06-09 23:12   ` David McClain
2001-06-09 23:28     ` David McClain
2001-06-10  1:04       ` Dave Mason
2001-06-10  2:25         ` David McClain
2001-06-11 13:03           ` Dave Mason
2001-06-12 17:55             ` John Max Skaller
2001-06-13 16:54               ` Frederick Smith
2001-06-13 21:43                 ` John Max Skaller
2001-06-10  1:06       ` Charles Martin
2001-06-10  2:27         ` David McClain
2001-06-10 11:18         ` Tore Lund
2001-06-10 13:11           ` Tore Lund
2001-06-10 14:31           ` John Max Skaller
2001-06-12 15:12             ` Pierre Weis
2001-06-10 10:40       ` Joerg Czeranski
2001-06-10 14:06       ` John Max Skaller
2001-06-11 12:59         ` Dave Mason
2001-06-12 17:34           ` John Max Skaller
2001-06-10 13:47   ` John Max Skaller
2001-06-10 16:47     ` Brian Rogoff
2001-06-10 17:27       ` Dave Mason
2001-06-12 16:10       ` John Max Skaller
2001-06-09 23:19 ` John Max Skaller

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=4A3567B6.4030002@univ-savoie.fr \
    --to=raffalli@univ-savoie.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    /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).