[Types-sig] MetaClasses (Non-ASCII art)

Just van Rossum just@letterror.com
Thu, 3 Dec 1998 03:19:21 +0100


Me:
>> I'm not sure why inheritance needs te be brought up here (or in any
>> metaclass discussion) at all: how exactly it works is to be defined by
>> class.__meta__.

M.-A. Lemburg wrote:
>Inheritance for meta objects can be very useful, e.g. in case
>all you want is to refine say the __meta_getattr__ method of
>Class to enable automatic acquisition or caching. You won't
>have to copy all the other implementation details: inheritance
>does this for you.

Sure, just add one more meta level which just implements
inheritance and you're still done...

Me:
>> What I'm really saying is, if you define
>>         getattr(object, attr)
>> as
>>         object.__meta__.__meta_getattr__(object, attr)
>> or as
>>         object.__class__.__class__.__meta_getattr__(object, attr)
>> You're basically done. The rest is implementation details... Now, which one
>> will it be?

M.-A. Lemburg wrote:
>Not really: classes and instances do different things to get
>at their attributes. Instances revert to their classes for help
>if they can't find an attribute, while classes try their
>base classes.

Sure, but they're _both_ implemented as classes, and they
just happen to define __meta_getattr__ differently. I don't see
how this has anything to do with inheritance. The class protocol
defines inheritance, but might be implemented using a meta
protocol which doesn't do inheritance. Or one that does, but that
one might be implemented using a meta protocol which doesn't
do inheritance. Or one that does, but that one might be
implemented using a meta protocol which doesn't do inheritance.
Or one that does, but that one might be implemented using a
meta protocol which doesn't do inheritance.

;-)

>This means two different implementations, so
>v.__meta__.__meta_getattr__ will in fact call getattr(v.__class__,name)
>which is implemented by v.__class__.__meta__.__meta_getattr__.

Yes, and? ;-)


Just