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 SAA26556 for caml-redistribution@pauillac.inria.fr; Fri, 25 Feb 2000 18:05:30 +0100 (MET) Resent-Message-Id: <200002251705.SAA26556@pauillac.inria.fr> Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA18789 for ; Fri, 25 Feb 2000 17:21:16 +0100 (MET) Received: from ruby (kyle100.zip.com.au [61.8.17.228]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id RAA05155 for ; Fri, 25 Feb 2000 17:21:05 +0100 (MET) Received: from maxtal.com.au (IDENT:root@localhost [127.0.0.1]) by ruby (8.9.3/8.9.3) with ESMTP id DAA24853; Sat, 26 Feb 2000 03:21:27 +1100 Sender: root@ruby Message-ID: <38B6AC06.691D5673@maxtal.com.au> Date: Sat, 26 Feb 2000 03:21:26 +1100 From: skaller Organization: Maxtal X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.12 i586) X-Accept-Language: en MIME-Version: 1.0 To: Stephan Houben CC: caml-list@inria.fr Subject: Re: symbol managment in Caml References: <20000225131622.A4595@pcrm.win.tue.nl> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Resent-From: weis@pauillac.inria.fr Resent-Date: Fri, 25 Feb 2000 18:05:29 +0100 Resent-To: caml-redistribution@pauillac.inria.fr Stephan Houben wrote: > > Hello list, > > I am writing an interpreter for a simple language in O'Caml. > The interpreter often needs to search a hash table with a string > as key. A common optimization for this is to use pointer identity > instead of string equality, and "intern" every string before using > it as a key to the hash table. > > Unfortunately, I don't see how to do this with the current O'Caml > libs. You can do identity checks with ==, but there seems no way > to get a good hash corresponding to ==. > > Has anyone already written some code for this task? No, but may I suggest using a hashtable of references to strings? The compiler will also need to keep a separate set of strings, which the hash table entries reference. I'd be interested in a performance comparison (since I have a similar interpreter :-) -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net