Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Re: ocaml sefault in bytecode: unanswered questions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Elnatan Reisner <elnatan@c...>
Subject: Re: [Caml-list] Re: ocaml sefault in bytecode: unanswered questions
On Mon, 2009-08-10 at 15:36 +0200, Martin Jambon wrote:
> Elnatan Reisner wrote:
> > On Sun, 2009-08-09 at 21:09 +0200, Alain Frisch wrote:
> >> Note that (=) sometimes terminates for cylic values.
> >>
> >> # type t = A of t | B of t;;
> >> type t = A of t | B of t
> >> # (let rec x = A x in x) = (let rec x = B x in x);;
> >> - : bool = false
> > 
> > Again, thanks for pointing this out. But can (=) ever evaluate to true
> > on cyclic structures?
> 
> Yes:
> 
> let rec x = `A x;;
> let o = object val x = x end;;
> o = o;;
> 
> -> true

Okay, give me one more try: Can (=) evaluate to true on cyclic
structures that are not objects? (My understanding is that objects are
compared---by both Pervasives.compare and by (=)---using only their
object ids, so [obj1 = obj2] is always just an comparison of two ints,
regardless of the contents of the objects. Is this correct?)

Also, I just tested out (>=), which the documentation says 'does not
terminate on cyclic structures':
# (let rec x = `A x in x) >= (let rec x = `B x in x);;
- : bool = false
So maybe my question went the wrong way: apparently the documentation of
(>=) should say 'may not terminate'.

Also, if I may, let me add two additional questions:
- Do (=), (<>), (<), (>), (<=), and (>=) all terminate on exactly the
same operands?
- Does Pervasives.compare terminate strictly more often, or are there
cases when the comparisons terminate but [compare x y] does not?

-Elnatan