[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: <email@example.com>
- Subject: Re: change-class
- From: Bruno Haible <firstname.lastname@example.org>
- Date: Fri, 17 Jan 1997 18:28:51 +0100
- In-reply-to: <9701151759.AA23360@ticco>
- References: <9701151759.AA23360@ticco>
Andreas Dietz <email@example.com> says:
> it seems that the CLOS implementation of CLISP does not contain
This is true. If you want CHANGE-CLASS in CLISP, you can use PCL instead
of the built-in CLOS. But it will be much slower.
> In my problem at hand, I only need to change the class of
> an object, no slots must be added or updated. How can I achieve the
> result of CHANGE-CLASS for this special case?
If you need CHANGE-CLASS (i.e. change an object's class while the
object remains EQ to what it was before), in my opinion you should
rethink about your class hierarchy.
As a general workaround: You can easily achieve your goal by
introducing an indirection class, like this:
(defclass <bozo> () (x y ...))
(defclass <bozo-container> ()
(indirection accessor: bozo-container-indirection)
;; Extend the accessors and any other generic functions so they automatically
;; follow the indirection.
(defmethod bozo-x ((object <bozo-container>))
(bozo-x (bozo-container-indirection object))
(defmethod (setf bozo-x) (new-value (object <bozo-container>))
((setf bozo-x) new-value (bozo-container-indirection object))