On 10 Aug 2003 01:01:21 +0200, I wrote:

> Hi!
> 
> I have an application where I will have two hash tables around, one
> to map certain objects to a structure providing information about
> them, the other one to map identifiers to objects (the same set of
> objects). I want both hash tables to be weak, i.e. I want the
> respective entries in both hash tables to disappear when the object
> in question is no longer referenced.
> 
> While other CL implementations like LW offer hash tables which can
> be "weak" with respect to their keys or values or both, CMUCL
> doesn't seem to have this feature. So, my idea for emulating this in
> CMUCL goes like this:
> 
> 1. Have a CMUCL-weak hash table H1 where the objects are keys and
>    the values are structures keeping information about the objects.
> 
> 2. Have another, normal, hash table H2 where the values are weak
>    pointers to the same objects.
> 
> 3. Once an object won't be referenced from elsewhere the respective
>    entry in H1 will disappear automatically while the weak pointer in
>    H2 which points to this object will be broken.
> 
>    Is that correct or do the weak hash key and the weak pointer
>    somehow interact and thus prevent the object from being garbage
>    collected?
> 
> 4. Lastly, I will establish a function in EXTENSIONS:*BEFORE-GC-HOOKS*
>    which will scan H2 for broken pointers and remove the corresponding
>    entries to completely simulate weak hash values.
> 
> Does this sound like a reasonable strategy or am I missing something?
> 
> Thanks,
> Edi.

Er, cough-cough, no replies yet. Was that too easy/dumb or did I
offend someone unintentionally?

Edi.

Reply via email to