caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: [Caml-list] Semantics of physical equality
@ 2004-02-27 23:16 Kevin S. Millikin
  2004-02-27 23:48 ` Michal Moskal
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin S. Millikin @ 2004-02-27 23:16 UTC (permalink / raw)
  To: 'Basile STARYNKEVITCH', caml-list

On Friday, February 27, 2004 3:32 PM, Basile STARYNKEVITCH 
[SMTP:basile@starynkevitch.net] wrote:
    >> On Fri, Feb 27, 2004 at 02:29:50PM -0600, Kevin S. Millikin
    >> wrote:
    >>
    >> # V1(0) == V1(0);; - : bool = false
    >>
    >> V1's are different.  Is this guaranteed?

    >> What do you mean by guaranteed?

I mean ``guaranteed'' in the sense that separate calls to cons in 
Scheme
are guaranteed to produce objects that are distinct (according to eqv?
and eq?), or that a call to malloc in C is guaranteed to never return a
pointer that is the same as any other currently valid pointer in the
program (according to ==).

    >> Why would you want a guarantee that V1 0 is not physically equal
    >> to V1 0? I tend to think that making such an hypothesis is
    >> dangerous and wrong, even if the current implementation
    >> demonstrate it.

For the same reason that I occasionally rely on separate cons cells not
being eq? in Scheme ;).  In the current problem, it can save me a great
deal of effort involved in generating temporary identifiers that are
guaranteed to be unique, and in wrapping library data structures that I
am unwilling to change in order merely to tag them.

I realize that it would be dangerous and wrong to rely on them being ==
if the semantics of value constructors and == did not guarantee they
would be.  So I guess that's my question: "is it dangerous and wrong to
rely on separately constructed values being different according to 
==?".

-- Kevin

PS: Anyway, it looks like Michal Moskal has answered in the negative.
Neither behavior is guaranteed, which is an acceptable answer (though
not the one I was looking for).

-------------------
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


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [Caml-list] Semantics of physical equality
@ 2004-02-27 20:29 Kevin S. Millikin
  2004-02-27 21:32 ` Basile STARYNKEVITCH
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin S. Millikin @ 2004-02-27 20:29 UTC (permalink / raw)
  To: 'caml-list@inria.fr'

I'm trying to figure out what I can rely on about physical equality. 
 I've checked the OCaml manual but can't seem to find what I want to 
know.

Presume

# type t = V0 | V1 of int;;
type t = V0 | V1 of int

# V0 == V0;;
- : bool = true

V0's are the same.  Is this guaranteed?

# V1(0) == V1(0);;
- : bool = false

V1's are different.  Is this guaranteed?

----
Kevin S. Millikin           Architecture Technology Corporation
Research Scientist          Specialists in Computer Architecture
(952)829-5864 x162          http://www.atcorp.com

-------------------
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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-02-29 19:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-27 23:16 [Caml-list] Semantics of physical equality Kevin S. Millikin
2004-02-27 23:48 ` Michal Moskal
2004-02-28  6:28   ` [Caml-list] " Jed Davis
  -- strict thread matches above, loose matches on Subject: below --
2004-02-27 20:29 [Caml-list] " 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
2004-02-28 10:34           ` Michal Moskal
2004-02-28 10:45             ` Andreas Rossberg
2004-02-28 11:25               ` Michal Moskal

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).