[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Restoring objects
- To: firstname.lastname@example.org
- Subject: Re: Restoring objects
- From: Steve Strassmann <email@example.com>
- Date: Thu, 28 May 1992 15:17:37 -0500
- Cc: info-mcl
>>> The only drawback with this is that no instance of cleanup-mixin
>>> will be gc'able. You can solve this by using weak hash tables
>>> (undocumented, but present in both 2.0b1 and 2.0 final).
>>What are "weak hash tables", how do they work, and what are they good
>A weak hash table is one whose elements will be GCed if they are no longer
>visible anywhere else. ie, the hash-table doesn't "count" as far as GC is
>I'll be damned if I can say what they're good for. I thought it would be
>good for data that would become dated, but then I realized that for
>reliability this would require a GC before each gethash, so that's not
>right...they must be good for something, but what? There couldn't possibly
>be a useless feature in Common LISP, now could there? :-)
Um, one thing they're good for is for caching things that are expensive
to compute, where you're not necessarily screwed if you have to compute
For example, let's say I wrote an AI program which follows soap operas.
I might infer some things like "all turtles belonging to the girlfriend
of the nephew of the hairdresser of the rock star are dying of potassium
overdoses", and cache this valuable insight in a hash-table.
If it becomes useful knowledge, I can retrieve it quickly. But if it
gets GC'd because it's not really used by anyone, no big deal. I get
my storage back, and the worst case is that I have to use my inference
engine all over again the next time I ask for this particular
piece of knowledge.