From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA09832; Mon, 23 Apr 2001 16:04:08 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA09939 for ; Mon, 23 Apr 2001 16:04:07 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f3NE46925268; Mon, 23 Apr 2001 16:04:06 +0200 (MET DST) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f3NE46q09318 ; Mon, 23 Apr 2001 16:04:06 +0200 (CEST) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.9.2/jb-1.1) id QAA07862 ; Mon, 23 Apr 2001 16:04:09 +0200 (MET DST) Date: Mon, 23 Apr 2001 16:04:09 +0200 (MET DST) From: Alain Frisch To: Xavier Leroy cc: Caml list Subject: Re: [Caml-list] equality over functional value In-Reply-To: <20010423095627.A517@pauillac.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 23 Apr 2001, Xavier Leroy wrote: > More generally, equality between functions can be interpreted in > several ways: >... > 3- By representation: two functions are equal iff their closures are > structurally equal, i.e. they have the same code pointer and contain > equal values in their environment. > > Interpretation 3- is useless I think, because it depends very much on > the compiler's closure representation strategy. In other terms, while > a "true" result guarantees that the two functions are extensionally > equal, a "false" result does not mean anything. For equality testing, this comparison doesn't make much sense. But it may be useful because it defines a total (quasi-)ordering on functional values whose associated equivalence is: - coarser than physical equality - finer than observational equivalence It is probably bad style to rely heavily on such an ordering, but it is sometimes annoying not to be able to use generic comparison function when you have functional types somewhere in your complex data structures. Even if you associate a "stamp" to functional values, you can't use generic comparisons. Having said that, being able to define custom operation for Caml values seems much more important and general to me. The interface may be something like: type 'a t type 'a operations = { compare: 'a -> 'a -> int ; hash : 'a -> int ; ... } val wrap : 'a operations -> 'a -> 'a t val extract : 'a t -> 'a -- Alain Frisch ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr