Re: mjc4y@brunelleschi.cs.virginia.edu: python object model

Kenneth Manheimer (klm@NIST.GOV)
Sat, 27 Aug 1994 20:03:35 -0400 (EDT)

I'm unclear about a particular point in the message of
deline@src.dec.com that guido recently forwarded, and hoping for
clarification.

I *think* that i grasp the use of metaclasses in principle, but i'm
new to the practice. My confusion concerns the distinction between
class inheritance:

> Given this, a Python programmer could create new metaclasses by subclassing,
> as follows. To borrow Matt's example,
>
> class SMART_CLASS(CLASS):
> [...]

and use of the 'is' qualifier for class definitions:

> There's only one place the syntax would need to be changed and that
> is to indicate that a class is an instance of a particular metaclass.
> Again, to borrow Matt's example:
>
> class SmartRect is SMART_CLASS:
> [...]

My provisional explanation of this is based on the guess that you're
talking about distinguishing two kinds of object methods. "Meta"
methods would implement things like the mechanism by which methods,
themselves, are invoked (invokemethod), or perhaps the mechanism by
which object attributes are added (addattribute). I presume that such
meta-methods would influence behavior of their objects across
operations. "Regular" methods would be the ones that only pertain to
specific operations on the object, like __add__, __div__, __repr__,
and __setitem__/__getitem__, etc.

Am i on the right track here?

And if so (big if), why is it necessary for inheritance of the meta
behaviors to be distinguished from inheritance of the "regular"
behaviors? Aside from determining the operations which are to be used
in the actual manufacture of a class object (eg, the 'addmethod'
method), i don't see why metaclass operations like invokemethod or
addattribute can't just be inherited like other methods. I'm not
suggesting that i doubt there is some reason, only that i don't see
what the reason is.

Thanks for any enlightenment,

Ken
ken.manheimer@nist.gov, 301 975-3539