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

Re: How to change inheritance of class options?



   Dear netters,
   I've created a metaclass with a particular behaviour, and made classes and
   objects using it.  Fine.  However, when I make a subclass of one of my new
   classes, it does not inherit the metaclass affiliation.

   To clarify:

   ? (defclass mc0 (standard-class) ())
   #<STANDARD-CLASS MC0>
   ? (defclass c0 () () (:metaclass mc0))
   #<MC0 C0>
   ? (defclass c1 (c0) ())
   #<STANDARD-CLASS C1>


   i.e., the class-option slot is not being inherited.  That is expected,
   described in Steele. However, what I would like to have is

   ? (defclass c1 (c0) ())
   #<MC0 C1>

   How can I do this? I have tried messing with the defclass macro (out of my
   league) and with make-instance (standard-class) and even default-initargs,
   but I can't make sense of it.  I have looked in the faq's, the MCL manual,
   Steele, and Kiczales and it just makes me feel foolish...

I explicitly provide the :METACLASS arg to all such defclasses.
Well, actually I hide it in my own DEFCLASS+ macro which defaults to
my metaclass (here is a very stripped down and somewhat oversimplified
version of my macro): 


(defmacro defclass+
  (class-name superclasses slots . class-options)

  `(defclass ,class-name
	  (,@superclasses standard-object+)
	  ,slots
	  ,@class-options
	  '(:metaclass standard-class+)))


I'm not completely sure that I'm addressing what you want, but I hope
this helps.


-Eric



--
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Eric L. Peterson
MITRE Corporation
Artificial Intelligence Technical Center
7525 Colshire Dr.
McLean, VA 22102-3481

Internet:  eric@starbase.mitre.org
Phone:  (703) 883-6116
Fax:  (703) 883-6435


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


		  "I never meta-class I didn't like"

				-anon
			     
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;