Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Semantics of physical equality
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Michal Moskal <malekith@p...>
Subject: Re: [Caml-list] Semantics of physical equality
On Sat, Feb 28, 2004 at 11:45:53AM +0100, Andreas Rossberg wrote:
> Michal Moskal <malekith@pld-linux.org> wrote:
> > > > 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.
> >
> > On integers and characters, physical equality is identical to structural
> > equality. [1]
> >
> > It depends what you mean by ,,guaranteed'' though.
> >
> > [1] http://caml.inria.fr/ocaml/htmlman/libref/Pervasives.html
> 
> You are right, I stand corrected. Int is a special case.
> 
> BTW, the manual speaks of "integers". Surely it only holds for plain type
> "int", not for other integer types, like big_int, int32, does it?

Nope, these are boxed.

# let x = Int32.of_int 42;;
val x : int32 = 42l
# let y = Int32.of_int 42;;
val y : int32 = 42l
# x = y;;
- : bool = true
# x == y;;
- : bool = false

I mean it is not guaranteed, and moreover is not the case in the current
implementation.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?

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