🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #410

RE: accessing clos objects

#410
From: Skip Egdorf
Date: Mon, 11 Feb 1991 21:08
39 lines
2251 bytes
>   ==> After I have created a class and I have instantiated
>       it with a number of objects, is there any function
>       I can use to access these objects later on without
>       refering to them by name.
>       In other words, is there any easy way to access all
>       the objects that belong to a given class?
>
>   Mike Bender

   Ummm... "without refering to them by name???" Do you really mean
"without keeping track of the instance object returned by
(make-instance ...) ?"

   CLOS does not currently name its instances. I believe that this is
because CLOS instances are supposed to be very lightweight
so that they can be used for things like intermediate representations
in new arithmetic systems.

   It is relatively easy to use the meta object protocol to add
functionality to a class such that it maintains a list of all instances,
and/or provides named instances. One adds a slot to each class object that
maintains a name-instance mapping. A global symbol table is nice
to allow global instance lookup by name.

   I have implemented such a metaclass using the accessors for
class name-object mapping as a model. This scheme allows
(class-direct-instances class), (instance-name object), (find-instance obect),
and (setf (instance-name object) ...) on any instances of classes of this
new metaclass.

So, to answer your question: No, there is no such function, but it is
easy to implement yourself for those classes where you need to access
all instances. It is an indication of some sort of success for the
CLOS design that it both provides for the notion of very lightweight instances,
and also gives the ability to easily extend the basis where needed.

					Skip Egdorf
					hwe@lanl.gov
Technical Details
Message-ID: <9102112108.AA02802@zaphod.lanl.gov.lanl.gov>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!spool.mu.edu!uunet!tut.cis.ohio-state.edu!ZAPHOD.LANL.GOV!egdorf
References: <MIKEB.91Feb11101840@wdl35.wdl.loral.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!spool.mu.edu!uunet!tut.cis.ohio-state.edu!ZAPHOD.LANL.GOV!egdorf
From: egdorf@ZAPHOD.LANL.GOV (Skip Egdorf)
Newsgroups: comp.lang.clos
Subject: RE: accessing clos objects
Message-ID: <9102112108.AA02802@zaphod.lanl.gov.lanl.gov>
Date: 11 Feb 91 21:08:44 GMT
References: <MIKEB.91Feb11101840@wdl35.wdl.loral.com>
Sender: welch@tut.cis.ohio-state.edu
Distribution: inet
Organization: CommonLoops
Lines: 39