[Python-Dev] Classes and Metaclasses in Smalltalk (original) (raw)

Thomas Heller thomas.heller@ion-tof.com
Wed, 2 May 2001 12:57:42 +0200


> The most common use for these seems to be for calling > inherited methods, so perhaps something like > > inherited MyBaseClass.foo(arg, ...) > > which would be equivalent to > > getmethod(MyBaseClass, 'foo')(self, arg, ...) > > where getmethod() is a new builtin like getattr() > except that it looks in the classdict, and 'self' > is really whatever the first argument of the containing > method was.

The second most common use is to reference class variables (e.g. imagine a class that keeps counters of how many instances have been created and deleted in C.initcount and C.delcount). But these should not have to change, since they really are class attributes. > Now that we have future, would such a change be contemplatable? > Or is it too radical to even think about? If we can find a way to spell "super.method", we should be ready for the future. I can't think of something right off the bat unfortunately.

Could we make

super(self, MyBaseClass).foo(arg, ...)

behave similar to

MyBaseClass.foo(self, arg, ...)

Wrapping this stuff in a function would probably also enable to use the same pattern in existing python versions.

Thomas