[Types-sig] Re: Meta-classes discussion starter

Donald Beaudry Donald Beaudry <donb@tensilica.com>
Tue, 01 Dec 1998 10:19:01 -0500


"Evan Simpson" <evan@tokenexchange.com> wrote,
> I can see how defining them, and specifiying their meta-classes, would solve
> the binding and naming problems.  You could even have multiple meta-classes
> just as you have multiple inheritance.

I guess you could, but since nobody can quite figure out why single
inheritance meta-classes are needed or what they might be used for,
I doubt that it would be a good idea!

> All you need now is a way to spell static methods.

How is specifying a static method any different than specifying a
method in a meta-class (for the benefit of the class)?  Or is that
what you are asking for?

A while back I proposed that meta-classes be specified by embedding
them in the class that needs it.  For example:

    class foo:
        class __class__:
            def some_class_method(self):
                # 'self' is a foo class object or one derived from it.
                ...

        def some_instance_method(self):
            # self
            ...

Then, foo.some_class_method() would be very similar to a 'static'
function in C++, while foo().some_instance_method() is just what we
expect today.  If a class was to be derived from foo, it would
"inherit" foo's meta-class.  More accurately though, any class derived
from foo would be an instance of the same meta-class as foo (unless of
course the derived class needs to specialize the meta-class).

(sorry if this has been discussed and tossed out already... I'm
 just starting to wake up)

	--Don