caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
To: caml-list <caml-list@inria.fr>
Subject: Request for weak functional map ...
Date: Fri, 02 Dec 2005 22:11:17 +0100	[thread overview]
Message-ID: <4390B875.3080206@univ-savoie.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]


Hi,

It is a the second time I am in need for this ... Let me explain.

I wish a data structure similar to the Map provided by standard library
(logarithmic insertion and deletion) ... but with a "weak key" behavior:

This means that when the key is no more accessible by the GC, all the
bindings of this key are erased in all maps by the next GC.

Typicaly, key will be records with a unique ID used for the comparison
... So when the key is no more accessible, you are sure the bindings to
this key are useless.

I think it is not trivial to implement this in the GC, but if you can
have a removal in balanced tree that does no allocation (reusing the
existing cell), then the sweep/copy phase of the GC could do the removal.

BTW: I think this is impossible to implement using the Weak module ...
but I am not so sure. (it may be possible to implement if you do not
have the logarithmic requirement in complexity, but all insertiosn will
copy a weak array and a standard array ... this is not reasonable).

BTW2: there is also a solution with a weak array/hashtbl of all maps
using a given key stored in the key record itself (you could point to
the nodes of the balanced tree using the key, and wait the next
insertion to rebalance the tree when deleting the key) ... then a
finaliser could do the removal job ... But this does not look nice,
because the data type for the key is not "free" anymore, and it also
looks quite bad for the complexity.

Are they other people that think this is a usefull feature to add to the
language ?

Is their functional languages that can do this ?

Christophe

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 894 bytes --]

             reply	other threads:[~2005-12-02 21:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-02 21:11 Christophe Raffalli [this message]
2005-12-03  0:21 ` [Caml-list] " skaller
2005-12-04 16:03 ` Stefan Monnier

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=4390B875.3080206@univ-savoie.fr \
    --to=christophe.raffalli@univ-savoie.fr \
    --cc=caml-list@inria.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).