[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GLOCs are going away.

From: Michael Livshin
Subject: Re: GLOCs are going away.
Date: 27 Jul 2001 20:28:06 +0300
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Copyleft)

Dirk Herrmann <address@hidden> writes:

> On 26 Jul 2001, Michael Livshin wrote:
> > is there any interesting use for weak pairs besides implementing weak
> > dictionaries?
> I can't tell there are many of them, but:  When I worked on the
> environments, I needed a list of weak objects in order to store the weak
> observers for each environment.  Since guile does not have weak pairs, I
> had to misuse a weak hashtable to emulate a weak list.

ah.  and would it be important for such weak pairs to look like normal
pairs (i.e. answer to `car' and `cdr')?

because if that is not a requirement, then nobody's really stopping
you from implementing such a thing as a smob, right?

> With respect to weak dictionaries:  Dictionaries can be implemented in a
> lot of different ways:  Trees, hash tables etc.  For each variant, there
> are in turn a lot of implementation possibilities.  Jay Glascoe has
> implemented a set of auto resizing hash tables, including a very generic
> solution, where the hash function and the equality predicate can be
> user-specified.
> Without weak pairs, for every dictionary implementation one has to provide
> the corresponding weak implementation.  Or, even worse, several weak
> implementations:  When do you want your dictionary entry to
> disappear?  Do you want it to disappear if the key gets collected, or do
> you also want the entry to disappear if there are no more references to
> the value, i. e. the hash table itself should not protect the value?  The
> implementation has to be done on the C level and the code has to interact
> with the garbage collector.

yes.  the weakness of a dictionary (keys, values, both, none) is a
property of the dictionary, not its elements, and the GC interaction
is also on the whole-dictionary basis, not element-by-element.  the
elements don't even have to be cons pairs, really.

[ i.e. I think we agree :) ]

I'm sorry, the teleportation booth you have reached is not in service at
this time. Please hand-reassemble your molecules or call an operator to
help you....

reply via email to

[Prev in Thread] Current Thread [Next in Thread]