caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Krishnaswami, Neel" <neelk@cswcasa.com>
To: "'Will Benton'" <willb@cs.wisc.edu>, caml-list@pauillac.inria.fr
Subject: RE: [Caml-list] Some things are more equal than others
Date: Thu, 8 Nov 2001 14:16:34 -0500	[thread overview]
Message-ID: <B1E4D3274D57D411BE8400D0B783FF32A8D597@exchange1.cswv.com> (raw)

Will Benton [mailto:willb@cs.wisc.edu] wrote:
> On Thu, 2001-11-08 at 12:34, Jim Farrand wrote:
> > I know that this is almost certainly a case of RTFM, but I 
> > can't seem to find the right place.  6.7.4 mentions "structural" and 
> > "physical" equality, but doesn't define either.
> 
> Someone on the list will correct me if I'm wrong, but to clarify your
> guess (which seems correct to me):  Physical equality is a pointer
> comparison -- i.e. "do these objects occupy the same memory location".

This is correct. (The one filip is that for unboxed integers the
requirement is that the bit pattern in the words be the same, since 
they aren't pointers.)

> I have assumed that, by "Structural equality", they mean *shallow*
> equivalence -- i.e. "do these objects have the same structure, but not
> necessarily the same content".  Is this correct?

This is not so. Eg, 

# [1, 2, 3] = [1, 2, 3];;
- : bool = true;

# [1, 2, 3] = [1, 2, 8];;
- : bool = false;

What (=) does is rather like the Scheme equal? predicate. It 
walks down the structure of the two objects you are comparing, 
and makes sure that the whole thing is equal. This means that
you can trick it into hanging with recursive structures:

type foo = Foo of foo

let rec x = Foo x
let rec y = Foo y

Then the expression (x = y) will not terminate, since the (=)
predicate will loop as it chases pointers infinitely.


--
Neel Krishnaswami
neelk@cswcasa.com
 
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2001-11-08 19:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-08 19:16 Krishnaswami, Neel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-11-08 18:34 Jim Farrand
2001-11-08 18:46 ` Will Benton

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=B1E4D3274D57D411BE8400D0B783FF32A8D597@exchange1.cswv.com \
    --to=neelk@cswcasa.com \
    --cc=caml-list@pauillac.inria.fr \
    --cc=willb@cs.wisc.edu \
    /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).