caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <frisch@clipper.ens.fr>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: Caml list <caml-list@inria.fr>
Subject: Re: [Caml-list] equality over functional value
Date: Mon, 23 Apr 2001 16:04:09 +0200 (MET DST)	[thread overview]
Message-ID: <Pine.GSO.4.04.10104231545320.23234-100000@clipper.ens.fr> (raw)
In-Reply-To: <20010423095627.A517@pauillac.inria.fr>

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


  reply	other threads:[~2001-04-23 14:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-20 20:12 Georges Brun-Cottan
2001-04-20 21:23 ` Alain Frisch
2001-04-21 11:32   ` Marcin 'Qrczak' Kowalczyk
2001-04-21 15:24 ` David Monniaux
2001-04-23  7:01 ` Jean-Christophe Filliatre
2001-04-23  7:56 ` Xavier Leroy
2001-04-23 14:04   ` Alain Frisch [this message]
2001-04-24  7:13   ` Fabrice Le Fessant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.04.10104231545320.23234-100000@clipper.ens.fr \
    --to=frisch@clipper.ens.fr \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).