Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2000-02-25 (17:05)
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
comparison (since I have a similar interpreter :-)

John (Max) Skaller,
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper
download Interscript