Re: Specializing slot-value-using-class in OpenMCL



On 2007-05-30, Slava Akhmechet <coffeemug@xxxxxxxxx> wrote:
Pascal Costanza <pc@xxxxxxxxx> writes:
I hope this helps.
Thank you, it helps a lot! I just tried the fix and it works. I
only have one last question. Why are metaclasses are not inherited?

(defclass a ()
(slot)
(:metaclass somemeta))

(defclass b ()
(slot2))

Metaclass of 'b' will be standard-class (which causes problems). I
manually added the metaclass declaration to all relevant class, but
is there a way to simply propagate it from base class?

I'm not Pascal, but did you mean

(defclass b (a)
(slot2)) ;^^^

?

As far as why it's not inherited, I don't know for sure, but it seems
to me that the inheritance of metaclass in the presence of multiple
inheritance would be very complex.

You'd probably do better to write a define-somemeta macro along the
lines of:

(defmacro define-somemeta (name &body body)
`(defclass ,name
,@body
(:metaclass somemeta)))

(untested)

-- Larry

.



Relevant Pages

  • Re: Inheritance and meta-classes
    ... Inheritance wise the metaclass sits between an object and its class. ... posting) but the singleton class of a class sits between the instance ...
    (comp.lang.ruby)
  • Re: Inheritance and meta-classes
    ... How do I find where a function is defined in the inheritance tree? ... Because of metaclass inheritance being cyclical I don't know where ... obj.metaclass.respond_to?, NoMethodError]) ...
    (comp.lang.ruby)
  • Re: Inheritance and meta-classes
    ... Inheritance wise it sits between an object and its class. ... but that's not a metaclass (although the ... singleton class it sits between the instance (the class object, e.g. Array) and its class in the same way an ordinary's object's singleton class does - which is also shown by the image you referred to in your posting. ...
    (comp.lang.ruby)
  • Inheritance and meta-classes
    ... I'm trying to work out where a method is defined in Rails. ... How do I find where a function is defined in the inheritance tree? ... Because of metaclass inheritance being cyclical I don't know where to ...
    (comp.lang.ruby)
  • Re: why does the mop handle default-initargs as persistent,
    ... Classes of your imagined metaclass ... It is unfortunate that your example jumps from defclass to ensure-class, ... desired for some new:my-option option to defclass. ...
    (comp.lang.lisp)