From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id B0E3FBC0A for ; Tue, 13 Feb 2007 23:14:13 +0100 (CET) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1DMEC8U006836 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 13 Feb 2007 23:14:13 +0100 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay03.plus.net with esmtp (Exim) id 1HH5ue-0006iu-EX for caml-list@yquem.inria.fr; Tue, 13 Feb 2007 22:14:12 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Patterns that evaluate Date: Tue, 13 Feb 2007 22:07:33 +0000 User-Agent: KMail/1.9.5 References: <45D23608.4030104@mcmaster.ca> In-Reply-To: <45D23608.4030104@mcmaster.ca> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200702132207.33793.jon@ffconsultancy.com> X-Miltered: at discorde with ID 45D23834.003 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml's:01 bug:01 afaik:01 ocaml's:01 ocaml:01 frog:98 wrote:01 wrote:01 caml-list:01 match:02 binding:02 jacques:03 let:03 mistaken:04 On Tuesday 13 February 2007 22:04, Jacques Carette wrote: > I recently wrote some ocaml code which "worked", but not as I > intended... The test cases I tried worked, but I should have tested > harder. Apparently I was under the mistaken impression that OCaml's > pattern-matching was more "first class"! So I wrote (in part): > > let buildsimp cast e f1 f2 = fun e1 -> fun e2 -> match (e1,e2) with > > | ({st = Some e}, _) -> e2 > > and I expected it to work. Only a code review by a colleague 'found' > this bug in my code. > > Question: would it be a difficult extension? This seemed so "natural", > I just "used" the feature before it was quite there yet ;-). F# just introduced active patterns, which does what you want AFAIK. Of course, you must disambiguate that from the OCaml's current interpretation of the above (binding "e"). -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists