[Python-Dev] Classes and Metaclasses in Smalltalk
Jeremy Hylton
jeremy@digicool.com
Wed, 2 May 2001 09:38:42 -0400 (EDT)
>>>>> "GvR" == Guido van Rossum <guido@digicool.com> writes:
>> Since I don't know much about Python's guts, I can't say how
>> implementable this is, but I like the spelling. The semantics
>> would be something like this (with adjustments to the reality of
>> Python's guts):
>>
>> * 'super' is a magic object that only makes sense inside a 'def'
>> inside a 'class' (at least for now; perhaps it could be
>> generalized to work at class scope as well as method scope, but
>> let's keep it simple)
GvR> Yes, that's about the only way it can be made to work. The
GvR> compiler will have to (1) detect that 'super' is a free
GvR> variable, and (2) make it a local and initialize it with the
GvR> proper magic. Or, to relieve the burden from the symbol table,
GvR> we could make super a keyword, at the cost of breaking existing
GvR> code.
GvR> I don't think super is needed outside methods.
It seems helpful to clarify here, since this came up in conversation
at PythonLabs just the other day with the yield statement.
If we try to avoid keywords, we have to take the "well, I don't see
anyone assigning to this name" route. If the compiler does not detect
any assignment to a nearly reserved word, like super, it would give
the use of that word special meaning.
There are a bunch of little problems. A module could (not necessarily
should) be designed to have a global name poked into its namespace;
this would break, because the name would already have transmogrified
from a regular variable into a special one. The use of exec or import
star would make it impossible for the word to take on its special
meaning.
So keywords really are a lot clearer, but they have the potential to
be incompatible.
Jeremy