I know this is possible, but i can't find how to do it!
Say i have
(deflcass aa ((name :initarg :name)))
(defclass bb ((name :initarg :name) (c :initarg :c)))
Then , if i have an instance of class aa, i would like to create an instance of bb with all similar slots which bb has in common with aa filled in from aa.
Is this possible? I think there is some inbuilt way to do this, but i'm not sure.
Thanks!
Combining Two Dissimlar Classes Slots
-
- Posts: 61
- Joined: Mon Jul 07, 2008 8:06 pm
- Location: Toowoomba, Queensland, Australia
- Contact:
Re: Combining Two Dissimlar Classes Slots
It jogged my memory, and I found change-class. HTH
Notice that name still has the given value, and the instance prints out as belonging to the BB class.
Code: Select all
(defclass aa () ((name :initarg :name :accessor name)))
(defclass bb () ((name :initarg :name :accessor name) (c :initarg :c)))
(defparameter ana (make-instance 'aa :name :jimmy))
(change-class ana 'bb)
ana
(name ana)
Re: Combining Two Dissimlar Classes Slots
Thanks1 Thats exactly what i was looking for 

-
- Posts: 61
- Joined: Mon Jul 07, 2008 8:06 pm
- Location: Toowoomba, Queensland, Australia
- Contact:
Re: Combining Two Dissimlar Classes Slots
My pleasure
. It's nice to be able to help out - and I'm gradually getting more proficient with Lisp.......... 

