[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changing the :metaclass of a class



;;; Why is it that when I change the :metaclass of a class, 
;;; the class instance is not changed?  For example:

(defclass COMPATIBLE-METACLASS-MIXIN () ())
(defmethod CHECK-SUPER-METACLASS-COMPATIBILITY 
    ((class COMPATIBLE-METACLASS-MIXIN) (super STANDARD-CLASS))
  t)

;;; Initial metaclass
(defclass FIRST-METACLASS
    (COMPATIBLE-METACLASS-MIXIN STANDARD-CLASS)
    ((SLOT1
      	:initform 1
	:accessor SLOT1)))

;;; Next metaclass
(defclass SECOND-METACLASS
    (FIRST-METACLASS)
    ((SLOT2
      	:initform 2
	:accessor SLOT2)))


;;; Initial class.
(defclass MYCLASS () ()
  (:metaclass FIRST-METACLASS))

;;; Notice the class is an instance of the FIRST-METACLASS class.
(describe (find-class 'myclass))
The class #<First-Metaclass MYCLASS 24226771> is an instance of class
#<Standard-Class FIRST-METACLASS 23664351>.
Name:                  MYCLASS
Class-Precedence-List: (MYCLASS OBJECT T)
Local-Supers:          (OBJECT)
Direct-Subclasses:     NIL



;;; Class redefinition
(defclass MYCLASS () ()
  (:metaclass SECOND-METACLASS))

;;; But the class is still an instance of the FIRST-METACLASS class!
(describe (find-class 'myclass))
The class #<First-Metaclass MYCLASS 24226771> is an instance of class
#<Standard-Class FIRST-METACLASS 23664351>.
Name:                  MYCLASS
Class-Precedence-List: (MYCLASS OBJECT T)
Local-Supers:          (OBJECT)
Direct-Subclasses:     NIL


Thanks for any assistance,
Darrell Shane

P.S. I am using "no cute name" PCL running on Franz Allegro CL.