Version française
Home     About     Download     Resources     Contact us    
Browse thread
Hashtbls with physical equality?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Wheeler Ruml <ruml@p...>
Subject: Re: [Caml-list] Hashtbls with physical equality?
> >>module PhysrefHashtbl =
> >>  Hashtbl.Make (struct type t = string
> >>    let equal = (==)
> >>    let hash = Hashtbl.hash
> >>  end)
> > 
> > My only concern about this solution is that Hashtbl.hash will walk over the
> > key's structure in order to compute its hash value.
> 
> Keep in mind that the hash function in the Hashtbl.Make functor can be 
> any function whose signature is t -> int. This allows you to tweak and 
> twine your hashing algorithm as you choose. If you don't want to right a 
> hashing algorithm from scratch, than parametrize Xavier's to your 
> heart's content:

OK, fair enough.  I guess there isn't any static "address-like" identity to
objects in OCaml, so I really do have to examine at least a few bits of the
object to compute a hash value.

Thanks very much for your help!

Wheeler
-- 
Wheeler Ruml, Palo Alto Research Center, Rm 1522, 650-812-4329 voice
ruml@parc.com, http://www.parc.com/ruml           650-812-4334 fax