Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@etu.upmc.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Side effect in non-commutative context
Date: Tue, 24 Aug 2004 11:54:39 +0200 (DST)	[thread overview]
Message-ID: <Pine.A41.4.44.0408241136590.569348-100000@ibm1> (raw)

    Bonjour,

I intoduced some time ago a bug when rewritting a code because of an
uncontrolled side effect in a non-commutative context :

I replaced

match continuations with
  | [] -> []
  | g :: tail ->
      let result =
         try
           Some (g ())
         with Fail -> None
      in
         match result with
           | None -> solve tail
           | Some r -> r :: solve tail


with the direct construction

  | g :: tail ->
     try
       g () :: solve tail
     with Fail -> solve tail

Since Caml evaluates from right to left, the exception that was being
catched was the one raised by [solve tail] and the correct result
computed by [g ()] was thrown. This bug would have been quite hard
to find if I hadn't had a working code to compare with (and even
like this it took me some time).

The right to left evaluation order if implemetation dependent and this
bug could have been there for a long time if Caml did happen to
evaluate in a left-to-right way.

Would it be possible to add to the caml compiler some detection and
reporting of side-effects in non-commutative (implementation
dependent) context ?


        Diego Olivier

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


             reply	other threads:[~2004-08-24  9:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-24  9:54 Diego Olivier Fernandez Pons [this message]
2004-08-26  9:01 ` Diego Olivier Fernandez Pons

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=Pine.A41.4.44.0408241136590.569348-100000@ibm1 \
    --to=diego.fernandez_pons@etu.upmc.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