From: Judicael Courant <Judicael.Courant@lri.fr>
To: Stephan Houben <stephan@pcrm.win.tue.nl>
Cc: caml-list@inria.fr
Subject: Re: symbol managment in Caml
Date: Fri, 25 Feb 2000 17:25:51 +0100 (MET) [thread overview]
Message-ID: <14518.44303.707274.695470@pc87> (raw)
In-Reply-To: <20000225131622.A4595@pcrm.win.tue.nl>
Hi,
In his message of Fri February 25, 2000, Stephan Houben writes:
>
> 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?
>
I guess it is very difficult to provide a good hash function
corresponding to == because the GC may move the block the string has
been allocated to at any time.
However, in older versions of Coq (http://coq.inria.fr) there was some
code achieving what you are looking for : roughly, identifiers were
internally represented as (unique) integers and we had two conversion
functions ident_of_string and string_of_ident (each time a new string
was interned through ident_of_string, a new integer was
allocated). Therefore, ident comparison was integer comparison, and we
had a hash function over idents.
NB : after a while, the code implementing this was removed from Coq
(we spent more time (re)interning terms than we saved...)
Judicaël Courant.
--
Judicael.Courant@lri.fr, http://www.lri.fr/~jcourant/
(+33) (0)1 69 15 64 85
"Montre moi des morceaux de ton monde, et je te montrerai le mien"
Tim, matricule #929, condamné à mort.
http://rozenn.picard.free.fr/tim.html
next prev parent reply other threads:[~2000-02-25 17:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-02-25 12:16 Stephan Houben
2000-02-25 16:21 ` skaller
2000-02-25 16:25 ` Judicael Courant [this message]
2000-02-25 17:10 ` Claudio Sacerdoti Coen
2000-02-26 6:13 ` Frank A. Christoph
2000-02-28 9:49 ` Sven LUTHER
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14518.44303.707274.695470@pc87 \
--to=judicael.courant@lri.fr \
--cc=caml-list@inria.fr \
--cc=stephan@pcrm.win.tue.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox