higuchi@karc.crl.go.jp (Hideyuki Higuchi) (05/30/91)
It's my little trivial question. Is a CLOS interpreter always has at least one reference to each instance? 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? Thank you. -- Hideyuki Higuchi Kansai Advanced Research Center Ministry of Posts & Telecommunications, JAPAN
barmar@think.com (Barry Margolin) (05/30/91)
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