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 SAA25782; Wed, 3 Oct 2001 18:55:02 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 SAA25778 for ; Wed, 3 Oct 2001 18:55:02 +0200 (MET DST) Received: from sundown.cs.cornell.edu (sundown.cs.cornell.edu [128.84.96.20]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f93Gt1n04844 for ; Wed, 3 Oct 2001 18:55:01 +0200 (MET DST) Received: from cs.cornell.edu (dhcp99-32.cs.cornell.edu [128.84.99.32]) by sundown.cs.cornell.edu (8.11.3/8.11.3/R-3.6) with ESMTP id f93Gsxi10331 for ; Wed, 3 Oct 2001 12:54:59 -0400 (EDT) Message-ID: <3BBB42E3.C8477709@cs.cornell.edu> Date: Wed, 03 Oct 2001 12:54:59 -0400 From: Dan Grossman X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: caml-list Subject: Re: [Caml-list] Pattern matcher no more supposed to warn on non exhaustive patterns ? References: <007201c14c32$37e4c5a0$060000c0@N7YYB> 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, 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, 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 | =============== 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