OO in Python? ^^
Christopher Subich
csubich.spam.block at spam.subich.block.com
Wed Dec 14 10:47:39 EST 2005
Antoon Pardon wrote:
> Suppose we would add type declarations in python.
> So we could do things like
>
> int: a
> object: b
>
> Some people seem to think that this would introduce static
> typing, but the only effect those staments need to have
> is that each time a variable is rebound an assert statement
> would implicitly be executed, checking whether the variable is
> still an instance of the declared type.
Doesn't work; duck typing is emphatically not subclass-typing. For this
system to still work and be as general as Python is now (without having
to make all variables 'object's), we'd need true interface checking.
That is, we'd have to be able to say:
implements + like int: a
or somesuch. This is a Hard problem, and not worth solving for the
simple benefit of checking type errors in code.
It might be worth solving for dynamic code optimization, but that's
still a ways off.
More information about the Python-list
mailing list