From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA25230 for caml-red; Thu, 25 May 2000 09:35:34 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA26585 for ; Thu, 25 May 2000 09:14:34 +0200 (MET DST) Received: from nenuphar.saclay.cea.fr (nenuphar.saclay.cea.fr [132.166.192.7]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e4P7EY919891 for ; Thu, 25 May 2000 09:14:34 +0200 (MET DST) Received: from muguet.saclay.cea.fr (muguet.saclay.cea.fr [132.166.192.6]) by nenuphar.saclay.cea.fr (8.9.1a/8.9.1/CEAnet-relay-5.0.D20+Y2K) with ESMTP id JAA07883 for ; Thu, 25 May 2000 09:14:34 +0200 (MET DST) Received: from harpie.saclay.cea.fr (harpie.saclay.cea.fr [132.166.133.152]) by muguet.saclay.cea.fr (8.9.1a/8.9.1/CEAnet-relay-5.2.D20+Y2K) with ESMTP id JAA05450; Thu, 25 May 2000 09:14:32 +0200 (MET DST) Received: by harpie.saclay.cea.fr (8.8.8+Sun/CEANET.2.0.1) id JAA25316; Thu, 25 May 2000 09:14:38 +0200 (MET DST) From: STARYNKEVITCH Basile MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <14636.53981.794797.171353@gargle.gargle.HOWL> Date: Thu, 25 May 2000 09:14:37 +0200 (MET DST) To: Manuel Fahndrich CC: caml-list@pauillac.inria.fr Subject: Alternative generic hash function In-Reply-To: <783D93998201D311B0CF00805FEAA07B7E9233@RED-MSG-42> References: <783D93998201D311B0CF00805FEAA07B7E9233@RED-MSG-42> X-Mailer: VM 6.72 under 21.1 (patch 9) "Canyonlands" XEmacs Lucid Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit Sender: weis >>>>> "Manuel" == Manuel Fahndrich writes: Manuel> The generic hash function Hashtbl.hash traverses into Manuel> mutable data structures. [...] Manuel> As was pointed out times before on this list, Hashtbl.hash Manuel> is thus unsuitable for hashing on data structures that Manuel> contain mutable data. Manuel> I'm wondering what the design rational is for this Manuel> choice. I'd rather have a generic hash function Manuel> (Hashtbl.hash_pure) that never looks into mutable Manuel> structures (skips refs and mutable fields of records and Manuel> classes). I disagree. And it is probably difficult to implement in current Ocaml (which lacks any reflective facilities). The runtime does not know about mutable fields! If I want to hash mutable data structure, I will provide a specific hashing function. What I am lacking of is an hashing function accepting parametric type. I would like to define type 'a symbol_t = { sym_name: string; sym_hash: int; sym_val: 'a option} Then have let make_symbol s = { sym_name= s; sym_hash= Hashtbl.hash s; sym_val= None} let hash_symbol { sym_hash= h } = h Unfortunately I cannot make an hashtable using hash_symbol as hashing function Actually, hashing is a difficult subject. Perhaps there should be several hashing modules in Ocaml stdlib? Regards N.B. Any opinions expressed here are only mine, and not of my organization. N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA. --------------------------------------------------------------------- Basile STARYNKEVITCH ---- Commissariat à l Energie Atomique DTA/LETI/DEIN/SLA * CEA/Saclay b.528 (p111f) * 91191 GIF/YVETTE CEDEX * France phone: 1,69.08.60.55; fax: 1.69.08.83.95 home: 1,46.65.45.53 email: Basile point Starynkevitch at cea point fr