From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 52BF7BC75 for ; Mon, 28 Feb 2005 11:32:28 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j1SAWR96019889 for ; Mon, 28 Feb 2005 11:32:28 +0100 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 LAA25678 for ; Mon, 28 Feb 2005 11:32:27 +0100 (MET) Received: from mta1.cl.cam.ac.uk (mta1.cl.cam.ac.uk [128.232.0.15]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1SAWRBE006807 for ; Mon, 28 Feb 2005 11:32:27 +0100 Received: from zonule.cl.cam.ac.uk ([128.232.9.23] helo=cl.cam.ac.uk ident=[a4bdGyi012S3WUlZdaEaQ4VcFRvWtGBp]) by mta1.cl.cam.ac.uk with esmtp (Exim 3.092 #1) id 1D5iCQ-0001qB-00; Mon, 28 Feb 2005 10:32:26 +0000 X-Mailer: exmh version 2.6.3-CL 04/04/2003 with nmh-1.0.4 X-Exmh-Isig-CompType: repl X-Exmh-Isig-Folder: cslists/caml To: Alex Baretta Cc: Ocaml Subject: Re: [Caml-list] Fragile pattern matching?! In-reply-to: Your message of "Mon, 28 Feb 2005 11:17:02 +0100." <4222EF9E.1030106@barettadeit.com> Mime-Version: 1.0 Content-Type: text/plain Date: Mon, 28 Feb 2005 10:32:26 +0000 From: Keith Wansbrough Message-Id: X-Miltered: at concorde with ID 4222F33B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4222F33B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 baretta:01 compiler:01 checker:01 checker:01 silently:01 bug:01 exception:01 writes:01 constructor:01 int:01 int:01 match:02 match:02 raise:03 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.9 required=5.0 tests=PLING_QUERY autolearn=disabled version=3.0.2 X-Spam-Level: Alex Baretta writes: > let to_int value = match value with > | Int x -> x > | _ -> raise Some_exception > > The compiler signals a warning for a fragile pattern matching at the "_" > character. > > Why in the world should this code signal such a warning? The reason is to do with code maintenance. When in future you add another constructor to the value type, the type checker will tell you the locations of all matches that have now become incomplete, so that you can fix them. But the match in "to_int" above will never become incomplete. If the type checker passed this silently, then a bug could easily be introduced. Hence the warning. HTH. --KW 8-)