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 TAA01374; Mon, 1 Dec 2003 19:06:41 +0100 (MET) 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 TAA01744 for ; Mon, 1 Dec 2003 19:06:40 +0100 (MET) Received: from mailhost.tni.fr (firewall.tni.fr [195.25.255.61]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hB1I6cr06151 for ; Mon, 1 Dec 2003 19:06:38 +0100 (MET) Received: from groscool.tni.fr ([127.0.0.1]) by mailhost.tni.fr (Netscape Messaging Server 3.62) with SMTP id 2754 for ; Mon, 1 Dec 2003 19:06:21 +0100 Received: from 192.168.7.60 by groscool.tni.fr (InterScan E-Mail VirusWall NT); Mon, 01 Dec 2003 19:06:21 +0100 Message-ID: <3FCB82AF.EC411F85@tni.fr> Date: Mon, 01 Dec 2003 19:04:31 +0100 From: "sebastien FURIC" X-Mailer: Mozilla 4.78 [fr] (Windows NT 5.0; U) X-Accept-Language: fr MIME-Version: 1.0 To: OCaml Mailing list Subject: Re: [Caml-list] Question References: <3FCB610E.932B363B@tni.fr> <87d6b84eg8.dlv@wanadoo.fr> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; furic:01 furic:01 tni-valiosys:01 caml-list:01 tni-valiosys:01 toto:01 toto:01 ecrit:01 int:01 int:01 writes:01 remi:01 vanicat:01 constructors:01 match:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Remi Vanicat a écrit : > > "sebastien FURIC" writes: > > > Hi, > > > > What do you think of the following code? > > > > # type toto = Toto of int | Titi of string;; > > type toto = Toto of int | Titi of string > > # let test t t' = match t, t' with > > | ((Toto _ | Titi _), Toto x | Toto x, (Toto _ | Titi _)) when x = 0 > > -> "OK" > > | _ -> "KO";; > > Characters 73-79: > > Warning: this pattern is unused. > > | ((Toto _ | Titi _), Toto x | Toto x, (Toto _ | Titi _)) when x = 0 > > -> "OK" > > ^^^^^^ > > I can't answer to your question, but with your example, one can do a: > > # let test t t' = match t, t' with > | ((Toto _ | Titi _), Toto 0 > | Toto 0, (Toto _ | Titi _)) when x = 0 -> "OK" > | _ -> "KO";; > > of course, this is not generalizable to any test. I could have even write: # let test t t' = match t, t' with | _, Toto 0 | Toto 0, _ -> "OK" | _ -> "KO";; The point is that my example is extracted from a "serious" project where I wrote something like: | ((Toto _ | Titi _), Toto x | Toto x, (Toto _ | Titi _)) when f(x) = 0 -> ... and where type toto has more than 2 constructors. Cheers, Sébastien. ------------------- 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