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=1.4 required=5.0 tests=SPF_NEUTRAL 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 5F6CEBC0A for ; Wed, 14 Feb 2007 19:20:40 +0100 (CET) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.230]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1EIKcNi005757 for ; Wed, 14 Feb 2007 19:20:39 +0100 Received: by nz-out-0506.google.com with SMTP id i11so292305nzh for ; Wed, 14 Feb 2007 10:20:38 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=Pl3wVAV8UQxdinVx1ZtPkAyH9sxEPKRD3PytT9V6C65Yn0iXet9LrRs0fghJoa0blHNQJ8XAILTxaqBBWrwz0VafYSjZgImvbdQ7sKcXMltd1MrkiiWHga+kgA4mHFn/lcfACea2c57ITQBTK90ZkweOZ/KkwgJ3gd9gNQoQBMA= Received: by 10.35.128.17 with SMTP id f17mr1328823pyn.1171477238318; Wed, 14 Feb 2007 10:20:38 -0800 (PST) Received: from ?192.168.0.7? ( [70.243.153.3]) by mx.google.com with ESMTP id c12sm4853320nzc.2007.02.14.10.20.36; Wed, 14 Feb 2007 10:20:37 -0800 (PST) Message-ID: <45D352F2.3080003@gmail.com> Date: Wed, 14 Feb 2007 12:20:34 -0600 From: Edgar Friendly User-Agent: Thunderbird 2.0b2 (X11/20070116) MIME-Version: 1.0 To: Jon Harrop Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Patterns that evaluate References: <45D23608.4030104@mcmaster.ca> <200702132207.33793.jon@ffconsultancy.com> In-Reply-To: <200702132207.33793.jon@ffconsultancy.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-j-chkmail-Score: MSGID : 45D352F6.002 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45D352F6.002 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 syntax:01 compiler:01 edgar:98 wrote:01 wrote:01 caml-list:01 match:02 match:02 constructs:02 binding:02 Jon Harrop wrote: > 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"). > The two options I see are: 1) noting a re-binding, and automatically testing against the value of that previous binding 2) extra syntax (maybe || instead of | before active match constructs) In the first case, there's backwards compatibility issues. Wouldn't it be useful to have the compiler warn on such uses, to make people aware of rebindings performed in their code? E.