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

Kenneth Manheimer (klm@NIST.GOV)
Thu, 25 Aug 1994 17:47:14 -0400 (EDT)

I *think* that i grasp the use of metaclasses in principle, but the
practice is new to me. I'm unclear about a particular point in
deline@src.dec.com's message (which guido recently forwarded to the
list). At the risk of sounding stupid (brave me), i'm going to ask a
question from the midst of my confusion.

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 shaky notion is based on the guess that you're talking about
compartmenting two kinds of object methods. "Meta" methods would
implement things like the mechanism for invocing methods, themselves
(invokemethod), or the mechanism by which object attributes are added
(addattribute). I guess such meta-methods would influence behavior of
their objects across operations. "Regular" methods operations would
be the ones that only pertain to specific operations on the object,
like __setitem__/__getitem__ and __add__/__div__, etc.

Am i on the right track here?

And if so (big if), why is it necessary that inheritance of the meta
behaviors is distinguished from inheritance of the "regular"
behaviors? Aside from determining the operations which are to be used
in the actual production of subclass object (eg, the 'addmethod'
method), i don't see why metaclass operations like invokemethod or
addattribute can't just be inherited like other operations. I'm not
saying that i doubt it would be messy, just that the reason - how - it
would be messy is obscure to me.

Thanks for any enlightenment,

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