From: skaller <skaller@users.sourceforge.net>
To: Zheng Li <li@pps.jussieu.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] [ANN] Weaktbl: a weak hash table library
Date: Tue, 02 Oct 2007 21:07:11 +1000 [thread overview]
Message-ID: <1191323231.28954.27.camel@rosella.wigram> (raw)
In-Reply-To: <87641q3ysp.fsf@pps.jussieu.fr>
On Tue, 2007-10-02 at 06:50 +0200, Zheng Li wrote:
> Hi,
> Weaktbl is yet another weak hash table library for OCaml. Its main features
> include:
>
> * Both keys and associated values are weakly stored. A binding exists until
> the key is no longer referenced anywhere
I'm a bit confused what it means..
If the key is weak, it is useless except for terms, i.e. variants
or records of another data structure, where you are placing a pointer
in the table as a key. You can't put values (int, float, etc) in the
key field, because they're immediately unreferenced.
So you could use this thing as a cache, where for example you have
a tree and calculate some property of each node, and cache it
in the table.
The problem is .. physical comparison in Ocaml is unstable,
so you cannot hash pointers using polymorphic hash,
but pointers are the only kind that persist.
So I have to conclude you must use the Weaktbl with a functor,
instantiating the hash function to something which does a computation
on the value, and this claim:
* The interface is fully compatible with the standard
Hashtbl library instead
of the hash sub-module of the Weak library, so
basically you can also use it
as an alternative of the standard Hashtbl
is misleading: I use Hashtbl extensively, but ALL my uses are
using the polymorphic interface with polymorphic hash,
so actually none of them will work with Weaktbl, which is
a pity.
Can you confirm or deny this analysis?
A weakly keyed table would be cool for term cache, since
it saves worrying about removing dangling references.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
next prev parent reply other threads:[~2007-10-02 11:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-02 4:50 Zheng Li
2007-10-02 11:07 ` skaller [this message]
2007-10-03 10:43 ` Zheng Li
2007-10-04 16:01 ` Zheng Li
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=1191323231.28954.27.camel@rosella.wigram \
--to=skaller@users.sourceforge.net \
--cc=caml-list@inria.fr \
--cc=li@pps.jussieu.fr \
/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;
as well as URLs for NNTP newsgroup(s).