From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 724F1BCDE for ; Mon, 15 Nov 2004 17:46:29 +0100 (CET) Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id iAFGkQVL031734 for ; Mon, 15 Nov 2004 17:46:28 +0100 Received: from katsura.parc.xerox.com ([13.2.18.21]) by alpha.xerox.com with SMTP id <139084(1)>; Mon, 15 Nov 2004 08:46:08 PST Received: (from ruml@localhost) by katsura.parc.xerox.com (8.12.8/8.12.8/PARC RedHat Custom Submit 1.3) id iAFGjr5w002376; Mon, 15 Nov 2004 08:45:53 -0800 From: Wheeler Ruml MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16792.56641.327236.665106@katsura.parc.xerox.com> Date: Mon, 15 Nov 2004 08:45:53 PST To: Alex Baretta Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Hashtbls with physical equality? In-Reply-To: <419883E3.9040805@barettadeit.com> References: <16791.56417.334890.765954@katsura.parc.xerox.com> <20041115012212.GA6561@artisan.com> <16792.4688.306149.402656@katsura.parc.xerox.com> <419883E3.9040805@barettadeit.com> X-Mailer: VM 7.07 under 21.4 (patch 12) "Portable Code" XEmacs Lucid X-Miltered: at concorde with ID 4198DD62.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; wheeler:01 caml-list:01 hashtbl:01 struct:01 hash:01 hashtbl:01 hash:01 functor:01 tweak:01 hashing:01 hashing:01 parametrize:01 xavier's:01 ocaml:01 wheeler:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: > >>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