Version française
Home     About     Download     Resources     Contact us    
Browse thread
type of ==
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] type of ==
On Monday 18 April 2005 10:18, Christophe DEHLINGER wrote:
> I was recently in a situation where I would have liked to be able to
> test physical equality on terms of possibly different types, but
> couldn't because of =='s 'a -> 'a -> bool type.
> Why isn't its type 'a -> 'b -> bool ? Is there more to the
> implementation of == than a simple physical, asm-level equality test ?
> Is it because of the semantics of == ? If so, is a 'a -> 'b -> bool
> equivalent possible / already existing ?

If there were an "'a -> 'b -> bool" physical equality test, how could it ever 
return "true"?

> I guess something like fun a b 
> -> a == (Obj.magic b) should work, but regular posts on this list have
> gradually scared me off from ever using the obscure Obj module.

Yes, if you're writing self-contained OCaml programs then you should never use 
Obj.

You may find the beginners list more appropriate for these kinds of questions, 
BTW.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists