Adding static typing to Python

Paul Rubin phr-n2002a at nightsong.com
Tue Feb 19 02:06:43 EST 2002


"Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> writes:
> The harder you try to hide the data, the more likely the programmer will
> find it "necessary" to work his/her butt off to reach it. 

That may happen in C++ but it doesn't happen appreciably in Java.
Java is designed to resist even malicious attempts to reach into
another object's data.

> Python's data hiding, which might be called "by suggestion," is IMHO
> better because the programmer *knows* when he/she has crossed the
> line, and can be prepared to take responsiblity for it.

I'm not that worked up about type declarations as a bug-avoidance
tool; type declarations mostly help optimizing compilers generate
efficient object code, which current Python implementations don't
attempt at all.  However, lack of declarations for local variables and
for object slots are shortcomings in Python (2.2 adds a slots
declaration).  For example, in pre-2.2 Python it's fairly easy to
subclass something and then create some instance variables in the
subclass that accidentally clobber instance variables from the parent
class.  2.2's slots declaration might fix that--I'm not sure, since
it's not documented in the manual and I'm not sure any more where the
description is.



More information about the Python-list mailing list