[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: insert classes?
- To: Joseph.Bates@WIZARD.OZ.CS.CMU.EDU
- Subject: Re: insert classes?
- From: Danny Bobrow <email@example.com>
- Date: Tue, 3 Apr 90 12:06 PDT
- Cc: CommonLoops.PA@Xerox.COM
- Redistributed: CommonLoops.PA
Date: Tue, 20 Mar 90 16:01:51 EST
Danny Bobrow writes,
Assume you had started with
(defclass a (b) ...)
(defclass c (b) ...) [*] [referenced below]
and then evaluate:
(defclass a (c) ...)
CLOS guarantees that the new definition will override the old one
and that instances of a will be updated to the new structure the
next time a method is called on them.
But this requires that the definition of A still be available when C
is to be inserted. Is it possible to do the insertion without having
to retain the text of the definition of A? That is, using only the
info on the line tagged by [*] above? (Or perhaps also using the
knowledge that A is a subclass of B.)
Sorry for the delay; I was away.
The problem you mention is one reason for have a metaobject protocol,
with classes as first class objects. So to do what you want,
(defclass c (b) ...)
(reinitialize-instance (find-class 'a)
:direct-superclasses (list (find-class 'c)))
This will change the direct-superclasses of A without affecting the
rest of its definition (e.g. slots defined, accessors).
This works in Rainy Day PCL.