caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
To: "Daniel Bünzli" <daniel.buenzli@epfl.ch>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] GC and map
Date: Mon, 15 May 2006 21:38:00 +0200	[thread overview]
Message-ID: <4468D898.4050909@univ-savoie.fr> (raw)
In-Reply-To: <5E0CCADE-4A12-47B7-A11A-B0CD949FE0F6@epfl.ch>

Daniel Bünzli wrote:
> Can't you just use weak hash tables [1] in some way to implement that ?
> 

In fact, to make it simpler, I want weak key functional map.

That is functional map where binding are GC-collected when the key is no 
more accessible by the GC. I did not present it this way, because this 
requires equal key to be physically equal which does not fit with 
functional map, but this is not a real problem in my case.

If I remember well previous investigations, it is tricky and ugly but 
possible to implement weak key imperative hash table from the poor weak 
array of OCaml.

But weak key functional map seems impossible (I have no proof ;-).

The use for that is to try it for an evaluator for a toy functional 
language where the key are variable names and the maps hold the value of 
the variables. I do not want to simplify maps by hand where some 
variables do not exists in specific closure and I had like the GC to do it.

Actually, this approach is not the one use in OCaml: when closures are 
build by OCaml, specific environments are build with only the required 
variables to make sure there is no memory leak. In my approach, you can 
share environments between many closures, but the scan of the 
environment by the GC is much more complex (not sure this is really a 
gain anyway)

> Best,
> 
> Daniel
> 
> [1] <http://caml.inria.fr/pub/docs/manual-ocaml/libref/Weak.html>


      reply	other threads:[~2006-05-15 19:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-15 12:32 Christophe Raffalli
2006-05-15 12:46 ` [Caml-list] " Daniel Bünzli
2006-05-15 19:38   ` Christophe Raffalli [this message]

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=4468D898.4050909@univ-savoie.fr \
    --to=christophe.raffalli@univ-savoie.fr \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@epfl.ch \
    /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).