This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Something like vector-grow available?



Jost Boekemeier wrote:
> I need it to dynamically grow the weak observer array.  Maybe I could
> (ab-)use a weak hash table to hold the weak observers with the key
> being the observer and the value always being #f.

why a vector at all?  so you can use the vector indices to access
observers?

you could use weak vectors (see scm_make_weak_vector) then.

> Hmm, no.  The weak observer array is an array, not a dictionary type.
> On the other hand i think it should also shrink when all weak
> observers have been garbage collected.  Hmm, a weak list ... :)

hmm, if you want the ability to shrink the vector, you probably don't
care about indices, right?

there're no weak lists in Guile, because there're no weak pairs.
you'd need a serious overhaul of object tagging to have weak pairs.
maybe it'll be possible when the GC mark bits are no longer stored
within the conses (and instead are stored separately, in "chunklets"
or some such, I believe Greg Harvey could tell more about this).

> This would all not be necessary if I could get a notification from
> the garbage collector when a certain cell has been gc'ed.  I think
> this is not possible at the moment.

ah.  this certainly is possible, look at libguile/guardians.h.

hmm, now that I think about this, the way guardians are implemented,
they could be used as perfectly nice weak lists!  all you need is a
way to access the 'live list' of a guardian from Scheme.  it is very
easy to implement and seems useful.  comments?  I admit I didn't think
about it a lot, maybe it's a terrible idea.

--mike.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]