Ed Leafe wrote:
On Oct 15, 2004, at 7:36 PM, dataangel wrote:
What's the going argument against it? Makes sense to me.
There are constructions in other languages whereby an call to theWhat's the going argument against it? Makes sense to me.
superclass method does not require an explicit name of the current
class. When an inherited method is augmented in a subclass, the call to
the superclass version of the method doesn't require any class
specification; each class knows its own hierarchy.
even multiple classes, not to mention the fact that class parents can be
dynamically reassigned.
In lanagues like Self, which is similar in its flexibility (but can
actually handle this sort of thing), the method itself inherits from the
object (it's kind of confusing to wrap your head around) so it can
figure out things like this, but Python doesn't work that way.
Think of it another way: since B can figure out how to execute a call
to a method that doesn't exist in B itself by looking into its class
hierarchy, why can't a call like self.super() execute the code that
would have been executed had the subclass not overridden the method in
the first place?
When an instance "b" (or say "c" which is an instance of class "C" whichto a method that doesn't exist in B itself by looking into its class
hierarchy, why can't a call like self.super() execute the code that
would have been executed had the subclass not overridden the method in
the first place?
is a subclass of "B") executes something like "self.foo", it starts
looking at the class of self. "super" actually starts further up the
chain - if self is "c", you want "A.foo" and not "B.foo" (which is what
you'd get if it tried to derive who "super" is based on "self").