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 04901BCAF for ; Wed, 29 Jun 2005 19:34:02 +0200 (CEST) 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 j5THY1Ok013798 for ; Wed, 29 Jun 2005 19:34:01 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA03217 for ; Wed, 29 Jun 2005 19:34:01 +0200 (MET DST) Received: from nexus.stwing.upenn.edu (NEXUS.STWING.UPENN.EDU [165.123.132.61]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j5THXxAH013795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 29 Jun 2005 19:34:00 +0200 Received: from localhost (localhost [127.0.0.1]) by nexus.stwing.upenn.edu (Postfix) with ESMTP id 181B6648F2 for ; Wed, 29 Jun 2005 13:33:59 -0400 (EDT) Received: from nexus.stwing.upenn.edu ([127.0.0.1]) by localhost (nexus.stwing.upenn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26403-02 for ; Wed, 29 Jun 2005 13:33:58 -0400 (EDT) Received: from force.stwing.upenn.edu (force.stwing.upenn.edu [165.123.132.65]) by nexus.stwing.upenn.edu (Postfix) with ESMTP id AA3D1648DC for ; Wed, 29 Jun 2005 13:33:58 -0400 (EDT) Received: by force.stwing.upenn.edu (Postfix, from userid 5302) id 4B05031F10; Wed, 29 Jun 2005 13:33:58 -0400 (EDT) Date: Wed, 29 Jun 2005 13:33:57 -0400 From: William Lovas To: "O'Caml Mailing List" Subject: Re: [Caml-list] Type abstraction and (polymorphic) equality Message-ID: <20050629173356.GB4090@force.stwing.upenn.edu> Mail-Followup-To: O'Caml Mailing List References: <20050629.023111.15476874.debian00@tiscali.be> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050629.023111.15476874.debian00@tiscali.be> User-Agent: Mutt/1.5.6i X-Virus-Scanned: amavisd-new at stwing.upenn.edu X-Miltered: at concorde with ID 42C2DB89.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42C2DB87.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; lovas:01 wlovas:01 stwing:01 caml-list:01 abstraction:01 christophe:01 troestler:01 compiler:01 caml-list:01 compiler:01 cheers:01 ...:98 ...:98 wrote:01 exception:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Wed, Jun 29, 2005 at 02:31:11AM +0200, Christophe TROESTLER wrote: > Let me start with a little story that happened to me recently. > [...] > > The problem was that the attached information (an additional field in > a record) was a cyclic data structure. From there on, all equality > tests became deadly! (I would have preferred to have the exception > Invalid_argument "equal: abstract value".) What made matters worse is > that the compiler could not help me to find the locations of such > problems -- which can be hidden e.g. in List.mem. Not a nice job to > do... A harrowing and tragic tale indeed! While not really a solution to your problems, you *can* obtain the "abstract value" exception behavior with a little trick; Jacques Garrigue posted about it to the list a couple of months ago: http://caml.inria.fr/pub/ml-archives/caml-list/2005/04/66b52e5c944a3bd4c45e8b68c450461a.en.html I say it's no solution because (a) it doesn't keep you from having to write your own equality predicate with a different name, and (b) the compiler gives you no static warnings about invalid uses -- might as well program in Scheme! ;) cheers, William