From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA22599; Tue, 24 Aug 2004 11:57:06 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA19980 for ; Tue, 24 Aug 2004 11:57:05 +0200 (MET DST) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7O9v4mL031601 for ; Tue, 24 Aug 2004 11:57:04 +0200 Received: from ibm3.cicrp.jussieu.fr (ibm3.cicrp.jussieu.fr [134.157.15.3]) by shiva.jussieu.fr (8.12.11/jtpda-5.4) with ESMTP id i7O9uA7O036085 for ; Tue, 24 Aug 2004 11:56:12 +0200 (CEST) X-Ids: 166 Received: from ibm1.cicrp.jussieu.fr (ibm1.cicrp.jussieu.fr [134.157.15.1]) by ibm3.cicrp.jussieu.fr (8.8.8/jtpda/mob-V8) with ESMTP id LAA45256 for ; Tue, 24 Aug 2004 11:54:52 +0200 Received: from localhost (fernande@localhost) by ibm1.cicrp.jussieu.fr (8.8.8/jtpda/mob-v8) with ESMTP id LAA667700 for ; Tue, 24 Aug 2004 11:54:40 +0200 X-Authentication-Warning: ibm1.cicrp.jussieu.fr: fernande owned process doing -bs Date: Tue, 24 Aug 2004 11:54:39 +0200 (DST) From: Diego Olivier Fernandez Pons X-X-Sender: fernande@ibm1 To: caml-list@inria.fr Subject: [Caml-list] Side effect in non-commutative context Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce with ID 412B10F0.005 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at shiva.jussieu.fr with ID 412B10BA.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Antivirus: scanned by sophie at shiva.jussieu.fr X-Loop: caml-list@inria.fr X-Spam: no; 0.00; pons:01 pons:01 etu:99 bug:01 catched:01 bug:01 compiler:01 fernandez:01 fernandez:01 evaluates:01 computed:01 caml:01 caml:01 side-effects:02 olivier:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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