From: "Andreas Rossberg" <AndreasRossberg@web.de>
To: "Michal Moskal" <malekith@pld-linux.org>, <caml-list@inria.fr>
Subject: Re: [Caml-list] Semantics of physical equality
Date: Sat, 28 Feb 2004 11:21:35 +0100 [thread overview]
Message-ID: <009401c3fde4$a4f58330$404a06d5@wiko> (raw)
In-Reply-To: <20040228095652.GA10435@roke.freak>
Michal Moskal <malekith@pld-linux.org> wrote:
> > type test =
> > {
> > mutable a:int;
> > b:int
> > };;
> >
> > let r = {a=0;b=2};;
> >
> > let x = r and y = r in
> > assert((x.a==y.a)&&(x.b==y.b)&&(x==y))
> > ;;
> >
> > Does this always ok ?
>
> Yes, of course. The objects x and y are physically equal (which implies
> physical equality of their fields).
No, because (x.a == x.a) is not comparing the fields themselves (you cannot
do that, fields are not first class), but the projected values. They may be
physically different. Consider:
type r = {mutable a : float}
let r = {a = 1.0}
let b = x.a == x.a
This will deliver false.
> But both r.a and r.b are ints, so it is always OK (== and = are the same
> on ints).
That is what the current implementation does, but it is not guaranteed.
- Andreas
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-02-28 10:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-27 20:29 Kevin S. Millikin
2004-02-27 21:32 ` Basile STARYNKEVITCH
2004-02-27 22:59 ` Michal Moskal
2004-02-28 9:40 ` sejourne kevin
2004-02-28 9:55 ` Andreas Rossberg
2004-02-28 10:07 ` Michal Moskal
2004-02-28 9:56 ` Michal Moskal
2004-02-28 10:21 ` Andreas Rossberg [this message]
2004-02-28 10:34 ` Michal Moskal
2004-02-28 10:45 ` Andreas Rossberg
2004-02-28 11:25 ` Michal Moskal
2004-02-27 23:16 Kevin S. Millikin
2004-02-27 23:48 ` Michal Moskal
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='009401c3fde4$a4f58330$404a06d5@wiko' \
--to=andreasrossberg@web.de \
--cc=caml-list@inria.fr \
--cc=malekith@pld-linux.org \
/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