What If..... Strong Types
peter at engcorp.com
Tue Jun 18 03:25:58 CEST 2002
Don Garrett wrote:
> I'm not suggesting any real changes to any, only proposing a thought
> What if Python had been built from the start with strong types? And I mean
> strong types, not strong typing. The distinction I am trying to draw is that
> variables would not be typed, but that all types would have rigid interfaces.
> Primarily, what if classes always had rigidly defined interfaces. I mean
> that public members had to be declared to exist, and that methods couldn't be
> modified on an instance. Private members could exist but would be really private.
It takes work to define those interfaces. In my opinion, unnecessary,
inconvenient, and unreadable work... And Python does have private
members, of course, for the right definition of private.
Preventing modifying methods on an instance would make some of my
automated testing really difficult, if not impossible.
I don't understand the "must be declared to exist" part. If they are declared
but not defined, they don't exist anyway. If they are defined, then they
already exist and a declaration is redundant. Or were you using some other
definitions of "define" and "declare"?
> My belief is that almost all the convenience of Python would be maintained,
> but that compilation, optimization, and automated code analysis would be simpler.
Given that other languages have these things, but do not have nearly the
maintainability and convenience of Python, I doubt that.
> I'm just wondering if the change would be good or bad. Would it really
> break anything important in Python today? Would it prevent any common errors?
> Would it help with automated code analysis (compilation and optimization
> included) as much as I think it would?
Fork a branch of Python and experiment!
I suppose, since Python is flexible and adding all these things to the
language would tend to make it more restrictive and, well, brittle, you
could probably call the language "Stick". :-)
More information about the Python-list