From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 656CFBB81 for ; Thu, 30 Dec 2004 04:30:02 +0100 (CET) Received: from smtp3.wanadoo.fr (smtp3.wanadoo.fr [193.252.22.28]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBU3U17p032667 for ; Thu, 30 Dec 2004 04:30:01 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf0308.wanadoo.fr (SMTP Server) with ESMTP id 2F5332000088 for ; Thu, 30 Dec 2004 04:30:01 +0100 (CET) Received: from Galois (Mix-Strasbourg-103-2-76.w80-12.abo.wanadoo.fr [80.12.35.76]) by mwinf0308.wanadoo.fr (SMTP Server) with ESMTP id 95D1E2000085 for ; Thu, 30 Dec 2004 04:30:00 +0100 (CET) Received: from evariste by Galois with local (Exim 4.34) id 1Cjqzr-0000yF-Nw for caml-list@yquem.inria.fr; Thu, 30 Dec 2004 04:29:08 +0100 Date: Thu, 30 Dec 2004 04:29:07 +0100 From: =?iso-8859-1?Q?S=E9bastien?= Hinderer To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] A basic question Message-ID: <20041230032907.GA3720@galois> Mail-Followup-To: caml-list@yquem.inria.fr References: <2145c6e80412291847c40fc92@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2145c6e80412291847c40fc92@mail.gmail.com> X-Miltered: at concorde with ID 41D37639.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ens-lyon:01 caml-list:01 right-hand:01 compiler:01 semantics:01 equality:01 variables:02 tricky:02 warnings:02 element:02 types:02 let:03 let:03 exhaustive:03 sebastien:05 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: Hi, > I don't understand why the following two > let [x;y;z] = [1;2;3] ;; > and > let [x;y;z] = [1;2;3;4] ;; > have warnings: "this pattern-matching is not exhaustive". This is because, for pattern-matching to work, the two lists _must_ have the same length, so that the nth element in the right-hand list can be assigned to the nth variable specified in the left-hand list. But, the compiler has no way to check that in every case, hence this warning. > I think they just setting values for x, y, and z. Of course, it is probably possible to find some heuristics to check the equality between lengths, making your first example work, but it'd be tricky. Concerning your second example, it is not that obvious to attach a good semantics to what you write, because the lists are of different lengths. Now, if the only thing you want to do is to assign values to several variables at the same time, you can do something like : let (x, y z) = (1, 2, 3);; Of course, the types of (x y, z) and (1, 2, 3) must be compatible. So, a phrase like let (x, y, z) = (1, 2, 3, 4);; is wrong. hth, Sébastien.