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

Just van Rossum just@letterror.com
Wed, 2 Dec 1998 14:42:04 +0100


At 10:40 AM +0100 12/2/98, M.-A. Lemburg wrote:
>It does... also looks a lot like what I posted to the egroups
>list. I'll just repost it here for simplicity:

Thanks, that is an interesting approach, which actually looks a lot like
the current class/type scheme... The major difference to my (possibly
wrong) view is that I think (actually, hope) your v.__meta__ is the same
object as v.__class__.__class__. So behavior always comes from one class
higher up in the class chain. Maybe this is just dumb. I'll find out...

[ ... ]
>Here is a sample of the implied protocol:
>
>Say you want to access the attribute 'v.a':
>
>v.a

Minor nitpick:

>--> v.__meta__.__getattr__(v,'a')

You can't call it __getattr__, since that means getting an attr from
__meta__. I propose __meta_getattr__. I find Barry's __findattr__
confusing, too, since it reminds me of JPython's use of findattr, which, if
I understood correctly, means something else again...

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__.

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?

Just