caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
To: Georges Brun-Cottan <gbruncot@emc.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] equality over functional value
Date: Mon, 23 Apr 2001 09:01:05 +0200 (MEST)	[thread overview]
Message-ID: <15075.54065.253514.205217@pc803> (raw)
In-Reply-To: <200104202012.QAA09326@lub0127.lss.emc.com>


Georges Brun-Cottan writes:
 > 
 > Hi, 
 > 
 > A friend of mine is just starting with ocaml. He was puzzled by the
 > following result:
 > 
 > # let a i = i;;
 > val a : 'a -> 'a = <fun>
 > # let b i = i;;
 > val b : 'a -> 'a = <fun>
 > # a=b;;
 > Uncaught exception: Invalid_argument "equal: functional value".
 > # a=a;;
 > - : bool = true
 > # 
 > 
 > That is 'a=a' does not return the expected exception.  Actually it
 > first hit this "curiosity" when creating a polymorphic 'sort' function
 > on lists - and by applying it to a [sort;sort..] list. It worked.
 > 
 > Is this a bug? 

I  don't  think this  behavior  is intentional,  but  it  has an  easy
explanation: for better efficiency, the structural comparison function
(in  byterun/compare.c)  first   tries  physical  equality,  and  then
structural equality if  there is no physical equality.  So in the case
of a=a, the answer is true because of physical equality.

Hope this helps,
-- 
Jean-Christophe FILLIATRE
  mailto:Jean-Christophe.Filliatre@lri.fr
  http://www.lri.fr/~filliatr
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-04-23  7:18 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 [this message]
2001-04-23  7:56 ` Xavier Leroy
2001-04-23 14:04   ` Alain Frisch
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=15075.54065.253514.205217@pc803 \
    --to=jean-christophe.filliatre@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=gbruncot@emc.com \
    /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).