Real Problems with Python
William Tanksley
wtanksle at hawking.armored.net
Wed Feb 16 16:42:52 EST 2000
On 15 Feb 2000 01:27:32 GMT, Neel Krishnaswami wrote:
>Justus Pendleton <justus at my-deja.com> wrote:
>> neelk at alum.mit.edu wrote:
>> > > > 3. Multiple inheritance is unsound
>> > > > By 'unsound' I mean that a method call to a method inherited by
>> > > > a subclass of two other classes can fail, even if that method
>> > > > call would work on an instance of the base class.
>So I looked at some other dynamic languages to see what they did.
>o Dylan -- forbids using MI when there are multiple slots with the
> same name.
>Other languages seem to either forbid name conflicts or just suck it
>up and live with an unsafe rule, which leads me to conclude that the
>moral is TANSTAAFL -- there ain't no such thing as a free lunch.
Sather uses yet another system, which I see as very interesting -- it
totally disallows inheritance of every kind (single AND multiple). In its
place it offers two concepts: interface and importation.
Let me give a pseudo-Python example:
# the base class
class First:
def fun(hmm):
print hmm
# this is how to exactly imitate Python's current
# behavior (assuming no extra error checks occur)
class Second(First):
import First
# here we 'subclass' from First, but we don't inherit _any_
# behavior or data.
class Third(First):
def fun(yadda):
print "Whee!", yadda
# Here the compiler will print an error message, because we don't define
# any implementation of the interface we claim.
class Fourth(First):
def boring():
print "braces are cool, indentation sucks!"
This is only a single-inheritance example, of course. The rest is left as
an excercise to the reader.
>Neel
--
-William "Billy" Tanksley, in hoc signo hack
More information about the Python-list
mailing list