[Python-Dev] Classes and Metaclasses in Smalltalk

Fredrik Lundh fredrik@pythonware.com
Wed, 2 May 2001 16:00:55 +0200


guido wrote:

> > class MyClass (BaseClass):
> >     def foo (self, arg1, arg2):
> >          super.foo(arg1, arg2)
>
> I'm sure that's everybody's favorite way to spell it!

not mine.  my brain contains far too much Python 1.5.2 code
for it to accept that some variables are dynamically scoped,
while others are lexically scoped.

why not spell it out:

    self.__super__.foo(arg1, arg2)

or

    self.super.foo(arg1, arg2)

or

    super(self).foo(arg1, arg2)

> Or, to relieve the burden from the symbol table, we could make super
> a keyword, at the cost of breaking existing code.

hey, how about introducing $ as a keyword prefix for newly introduced
keywords?

    $super.foo(arg1, arg2)

(this can of course be mapped to either of my previous suggestions;
"$foo" either means "self.foo" or "foo(self)"...)

and to save a little typing, only use it for keywords that start with
an "s" (should leave us plenty of expansion room):

    $uper.foo(arg1, arg2)

otoh, if "super" is common enough to motivate introducing magic objects
into python, maybe "$" should mean "super."?

    $foo(arg1, arg2)

and while we're at it, let's introduce "@" for "self.".

gotta run -- time for my monthly reboot /F