On Wed, 13 Aug 2003 16:21:19 +0200, james anderson <[EMAIL PROTECTED]> wrote:

> >> 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.
> >>
> >> ...
> >> 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?
> >
> i'm surprised that you would not want H2 to be weak on the key. it's
> purpose is to permit users to retain the objects by virtue of
> binding the keys, isn't it? done this way, it takes two passes to
> release the objects, but no gc hooks. in either case, my concern
> would be about references from the object to its respective key,
> unless the gc implementation makes allowances for that.  ...

That won't work in my case (unless I'm missing something) because the
keys of H2 will be fixnums so the will never go away.

The idea is that

  (gethash <object FOO> H1)     -->    <structure with info about FOO>
  (gethash 123 H2)              -->    <object FOO>

These will be arbitrary fixnums so an array won't work.

Thanks,
Edi.

Reply via email to