Version française
Home     About     Download     Resources     Contact us    
Browse thread
symbol managment in Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@m...>
Subject: Re: symbol managment in Caml
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