[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Christophe Raffalli <christophe.raffalli@u...> |
| Subject: | Re: [Caml-list] GC and map |
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>