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.1 required=5.0 tests=AWL,MAILTO_TO_SPAM_ADDR 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 D93FEBD23 for ; Sun, 12 Aug 2007 14:05:57 +0200 (CEST) Received: from postar.fmf.uni-lj.si (vega.fmf.uni-lj.si [193.2.67.45]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7CC5vSn009193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 12 Aug 2007 14:05:57 +0200 Received: from localhost (unknown [192.168.5.1]) by postar.fmf.uni-lj.si (Postfix) with ESMTP id C6108165553; Sun, 12 Aug 2007 14:05:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at spam.fmf.uni-lj.si Received: from postar.fmf.uni-lj.si ([192.168.5.5]) by localhost (spam.fmf.uni-lj.si [192.168.5.1]) (amavisd-new, port 10024) with ESMTP id V8S2LK4H67gg; Sun, 12 Aug 2007 14:05:56 +0200 (CEST) Received: from [192.168.1.100] (BSN-77-148-136.static.dsl.siol.net [193.77.148.136]) (Authenticated sender: bauer) by postar.fmf.uni-lj.si (Postfix) with ESMTP id 0138D16554D; Sun, 12 Aug 2007 14:05:53 +0200 (CEST) Message-ID: <46BEF7A0.9030204@fmf.uni-lj.si> Date: Sun, 12 Aug 2007 14:05:52 +0200 From: Andrej Bauer Reply-To: Andrej.Bauer@andrej.com User-Agent: Thunderbird 1.5.0.12 (X11/20070604) MIME-Version: 1.0 To: caml-list@inria.fr Cc: tmp123@menta.net Subject: Re: [Caml-list] Sorted list References: <46B4485B.7040406@menta.net> <46B454ED.700@philippewang.info> <1186226538.14440.105.camel@rosella.wigram> <46B49875.3070206@menta.net> In-Reply-To: <46B49875.3070206@menta.net> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46BEF7A5.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; andrej:01 andrej:01 pointers:01 runtime:01 sml:01 equality:01 equality:01 wrote:01 abstract:01 abstract:01 exception:01 caml-list:01 compares:01 ids:01 functional:02 tmp123@menta.net wrote: > It seems dificult to generate an unique identifier, for this subject or any > other (in this sense, I feel nostalgic of the old C pointers). You can use references for that: type id = unit ref (** [unique_id ()] returns a unique reference. *) let unique_id () = ref () (** [equal_id id1 id2] compares two ids for equality. *) let equal_id id1 id2 = (id1 == id2) Now the trouble here is that you might accidentally compare id's with = instead of ==. If I use references to functional values then I get a runtime exception rather than a type error. Abstract types don't help either, so I am out of ideas. There are many theoretical reasons why abstract types should have their own user-defined equality tests (and the user might choose not to have an equality test at all). Where do PL designers like Xavier stand on this? SML has equality types (but that's not what I am talking about). Best regards, Andrej