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 UAA00779; Wed, 3 Oct 2001 20:07:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA00775 for ; Wed, 3 Oct 2001 20:07:09 +0200 (MET DST) Received: from beaune.inria.fr (beaune.inria.fr [128.93.8.3]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f93I78f10548 for ; Wed, 3 Oct 2001 20:07:08 +0200 (MET DST) Received: by beaune.inria.fr (8.8.8/1.1.22.3/14Sep99-0328PM) id UAA0000026808; Wed, 3 Oct 2001 20:07:08 +0200 (MET DST) From: Luc Maranget Message-Id: <200110031807.UAA0000026808@beaune.inria.fr> Subject: Re: [Caml-list] Pattern matcher no more supposed to warn on non To: danieljg@cs.cornell.edu (Dan Grossman) Date: Wed, 3 Oct 2001 20:07:08 +0200 (MET DST) Cc: caml-list@inria.fr (caml-list) In-Reply-To: <3BBB42E3.C8477709@cs.cornell.edu> from "Dan Grossman" at oct 03, 2001 12:54:59 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > > So long as the issue of when clauses has come up, Well I am thinking about it, others complain loudly. > I'll also point out that > the pattern-compiler essentially assumes that when clauses are pure. I'm > not complaining because I consider it poor style to violate this assumption, You bet. > but I've never heard it discussed anywhere. > For the program below, ocamlopt version 3.00 produces a program that prints > 1314. > > --Dan > > -- > | Dan Grossman www.cs.cornell.edu/home/danieljg H:607 256 0724 | > | 5157 Upson Hall danieljg@cs.cornell.edu O:607 255 9834 | Argl.... Dear Dan, which result would you consider to be correct ? (1111 ?) Please tell me... (Note that I see no consitency either in 3.02 or 3.00,) Cheers, thanks, and argl again ! --Luc It is worth a warning in the manual, at least... > > =============== > > type y = {mutable c:bool} > type x = {a:y; b:y} > > let f1 (v:x) = > match v with > {a = _; b = _} when (v.a.c <- false; v.b.c <- false; false) -> 0 > | {a = {c=false}; b = {c=false}} -> 1 > | {a = {c=false}; b = {c=true}} -> 2 > | {a = {c=true}; b = {c=false}} -> 3 > | {a = {c=true}; b = {c=true}} -> 4 > > let f2 (v:x) = > match v with > {a = {c=true}; b = _} when (v.a.c <- false; v.b.c <- false; false) -> 0 > | {a = {c=false}; b = {c=false}} -> 1 > | {a = {c=false}; b = {c=true}} -> 2 > | {a = {c=true}; b = {c=false}} -> 3 > | {a = {c=true}; b = {c=true}} -> 4 > > let f3 (v:x) = > match v with > {a = _; b = {c=true}} when (v.a.c <- false; v.b.c <- false; false) -> 0 > | {a = {c=false}; b = {c=false}} -> 1 > | {a = {c=false}; b = {c=true}} -> 2 > | {a = {c=true}; b = {c=false}} -> 3 > | {a = {c=true}; b = {c=true}} -> 4 > > let f4 (v:x) = > match v with > {a = {c=true}; b={c=true}} when (v.a.c <- false; v.b.c <- false; false) > -> 0 > | {a = {c=false}; b = {c=false}} -> 1 > | {a = {c=false}; b = {c=true}} -> 2 > | {a = {c=true}; b = {c=false}} -> 3 > | {a = {c=true}; b = {c=true}} -> 4 > > let main () = > let v1:x = {a = {c=true}; b = {c=true}} in > let v2:x = {a = {c=true}; b = {c=true}} in > let v3:x = {a = {c=true}; b = {c=true}} in > let v4:x = {a = {c=true}; b = {c=true}} in > print_int (f1 v1); > print_int (f2 v2); > print_int (f3 v3); > print_int (f4 v4) > > let _ = main () > ------------------- > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ > 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/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr