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 99ECEBC0A for ; Wed, 14 Feb 2007 20:10:21 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1EJAKCO019807 for ; Wed, 14 Feb 2007 20:10:21 +0100 Received: by ug-out-1314.google.com with SMTP id q2so331007uge for ; Wed, 14 Feb 2007 11:10:20 -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=bsKaxGD3TCHXrZNccDg/VEBuDGHt9Ni37uZRlBvQAriiNKdq+jdufgI1I28oEinsKq1D3GIyORkx2jc5ymqF5pcEb4WDN2U/IwX2a65KcjZcpMfurqebecyP25mQqxoJBytwnO5t6pFQZVZDEmvq+VxE7pGWjxYTaEia6SLzRwU= Received: by 10.78.157.8 with SMTP id f8mr299322hue.1171480220389; Wed, 14 Feb 2007 11:10:20 -0800 (PST) Received: by 10.78.100.6 with HTTP; Wed, 14 Feb 2007 11:10:20 -0800 (PST) Message-ID: <6dbd4d000702141110o12e2c703m7638b50029fd57a9@mail.gmail.com> Date: Wed, 14 Feb 2007 14:10:20 -0500 From: "Denis Bueno" To: "Gerd Stolpmann" Subject: Re: [Caml-list] Patterns that evaluate Cc: "Edgar Friendly" , caml-list@yquem.inria.fr In-Reply-To: <1171479313.24335.33.camel@localhost.localdomain> 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> <200702132207.33793.jon@ffconsultancy.com> <45D352F2.3080003@gmail.com> <1171479313.24335.33.camel@localhost.localdomain> X-j-chkmail-Score: MSGID : 45D35E9C.001 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45D35E9C.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; gerd:01 stolpmann:01 syntax:01 semantics:01 o'caml:01 gerd:01 compiler:01 defines:01 equality:01 equality:01 wrote:01 caml-list:01 matched:01 functions:01 constraint:01 On 2/14/07, Gerd Stolpmann wrote: > You are a bit quick. Before discussing syntax it is more important to > define the semantics of such patterns. I mean we have already three > predefined kinds of equality in O'Caml: > > - ( == ) > - ( = ) > - (fun x y -> compare x y = 0) > > I admit I do not prefer any one of them. So which equality should be > used to test whether the variable is equal to the matched part of the > value? > > I guess this simple question is one of the reasons why such a feature is > not in the language up to now. I agree with Gerd: equality is a hard thing to get right. For many months now I have been working on a compiler for a constraint solving language, and I always need to spend a significant amount of time, after the creation of each data structure, defining comparisons on instances of those structures. Usually there is one that defines an ordering for the purpose of using instances as keys in a Map; and sometimes there are additional equivalence relations that compare different aspects of structures. The principle then, applied to this problem, is: immediately *someone* is going to need a comparison function other than the ones above. And if there is no support for such functions, many people will consider the feature useless for all but the simplest of tasks. If there is support, it will become a question of just how convenient that support is. These aren't necessarily un-answerable questions; but they are not easy. -Denis