Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] getting the type of a polymorphic data ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@e...>
Subject: Re: [Caml-list] getting the type of a polymorphic data ?
    Bonjour,

> > Is it reasonable to admit that if Obj.is_int is true for x and y then
> > Hashtbl.hash is injective ?
>
> No.
>
> # type foo = A | B;;
> # let _ = Obj.is_int (Obj.repr 0);;
> - : bool = true
> # let _ = Obj.is_int (Obj.repr A);;
> - : bool = true
> # let _ = Hashtbl.hash A;;
> - : int = 0
> # let _ = Hashtbl.hash 0;;
> - : int = 0

I meant injective for a given (fixed) type. Obviously it won't in a
completely general case !

> The purpose of Hashtbl.hash is exactly no to be injective ! And
> hashing lists can't be injective.

That is why I said "isomorphic to a (finite) subset of (machine)
integers". And I said "isomorphic", not "in bijection" to be able to
add a few properties behind when needed and exclude the N x N ~ N
argument.

        Diego Olivier

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