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.1 required=5.0 tests=AWL,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 49188BC0A for ; Thu, 15 Feb 2007 21:43:24 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.170]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1FKhNGf032593 for ; Thu, 15 Feb 2007 21:43:23 +0100 Received: by ug-out-1314.google.com with SMTP id k3so273123ugf for ; Thu, 15 Feb 2007 12:43:23 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=EyL/dXAub3R1H2kLQL+Vi0SSeYOKk2xc/w8cgoPNMz8ADa+Pnp9wx+FWAFJt0ODntt8XxikH2qeYuvbEkYe4PBV4HVXff+RYWpKg7A/+mePxV1+0v4f+zKXbipnPi5C5bP06GKLh29cVvu//G0Z3Gl5iVkUASWC1HQymK23pXKE= Received: by 10.78.17.4 with SMTP id 4mr495602huq.1171572202795; Thu, 15 Feb 2007 12:43:22 -0800 (PST) Received: by 10.78.198.14 with HTTP; Thu, 15 Feb 2007 12:43:22 -0800 (PST) Message-ID: Date: Thu, 15 Feb 2007 12:43:22 -0800 From: "Nathaniel Gray" To: "Jacques Carette" Subject: Re: [Caml-list] Patterns that evaluate Cc: OCaml In-Reply-To: <45D37AD0.3090002@mcmaster.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45D23608.4030104@mcmaster.ca> <45D37AD0.3090002@mcmaster.ca> X-j-chkmail-Score: MSGID : 45D4C5EB.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45D4C5EB.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bug:01 syntax:01 mismatch:01 ocaml:01 compiler:01 ocaml:01 haskell:01 'when':01 overloading:01 cheers:01 grief:98 wrote:01 wrote:01 imho:01 syntactic:01 On 2/14/07, Jacques Carette wrote: > Nathaniel Gray wrote: > > On 2/13/07, Jacques Carette wrote: > >> 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. > > > > I guess I'm not seeing it. How did you expect it to work? Is this > > what you mean: > > > > ... | ({st = Some v}, _) when v = e -> e2 > Yes. that is what I meant. > > > Is there some functionality that you're looking for that when clauses > > don't provide? > No, there is not. I was just (mistakenly) assuming that the "more > pleasant" syntax for this ``worked''. > > Explanation: when I was a language designer, I learned a lot from user > 'mistakes' like this. Such mistakes told me of the mismatch between > user expectations and current reality. So I try to take the time to > document my own 'mistakes'. > Philosophy: if I don't take the time to give feedback, why should I > expect users of my own work to be any different? That's fine. I just wasn't sure what you expected to happen. I made the same mistake myself when I was learning OCaml, but I don't think it's something that should be changed. It's good to minimize new user mistakes, but you need to make a distinction between mistakes that new users make once and never make again versus those that cause ongoing grief. I think this is definitely the former. It only takes one "bite" to make you understand that pattern matches don't compute. One potential "solution" to this problem for new users would be a compiler warning when you shadow an existing variable in an explicit pattern match. > PS: there is no real functionality that I am looking for that Turing > Machines don't provide (or C or Java or ...). And yet I prefer > languages like (Meta)OCaml and Haskell. The "raw functionality" > argument does not seem to be the optimal way to look at these issues, IMHO. Maybe, but the "it's all equivalent to Turing machines" argument is pointless outside of formal proofs. Proposing some syntactic sugar for 'when' clauses is a very different thing from, say, proposing type classes and operator overloading, even though neither one has any impact on what the language can compute. Cheers, -n8 -- >>>-- Nathaniel Gray -- Caltech Computer Science ------> >>>-- Mojave Project -- http://mojave.cs.caltech.edu -->