Newsgroups: comp.lang.clos
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!barmar
From: barmar@think.com (Barry Margolin)
Subject: Re: Beginner's question on no referenced instance
Message-ID: <1991May30.093759.13233@Think.COM>
Sender: news@Think.COM
Reply-To: barmar@think.com
Organization: Thinking Machines Corporation, Cambridge MA, USA
References: <HIGUCHI.91May30123636@asagao.karc.crl.go.jp>
Distribution: comp
Date: Thu, 30 May 91 09:37:59 GMT

In article <HIGUCHI.91May30123636@asagao.karc.crl.go.jp> higuchi@karc.crl.go.jp (Hideyuki Higuchi) writes:
>I think a class object has to maintain instances lists for
>"make-instances-obsolete" or other functions, so each instance will never
>GCed. Is it true?

No.  Here's one simple way to implement make-instances-obsolete without a
list of instances:

All instances could have an internal "creation-time" slot, and all classes
would have a "modification-time" slot.  MAKE-INSTANCES-OBSOLETE updates the
class's modification time (and perhaps all its subclasses, too).  Whenever
an instance is used, its creation time is compared to the modification time
of its class -- if the creation time is older than the class's modification
time then the instance is obsolete and should be updated.

Even if the implementation does keep track of instances, this may not
prevent GCing.  Many Lisp implementations include something called "weak
pointers", which are pointers that are not traversed by the garbage
collector, so they don't prevent the object from being GCed.

-- 
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar
