What If..... Strong Types
Don Garrett
garrett at bgb.cc
Wed Jun 19 00:48:36 EDT 2002
Huaiyu Zhu wrote:
> Don Garrett <garrett at bgb.cc> wrote:
>
>> I'm not suggesting any real changes to any, only proposing a thought
>>experiment.
>>
>> 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.
>>
>> All types would be classes (including ints and such). Amoung other things,
>>I would add the concepts of Interfaces, instanceof operators.
>>
>> Local variables would not require declaration, and would work just like
>>today. Introspection would work, but be read-only.
>>
>> My belief is that almost all the convenience of Python would be maintained,
>>but that compilation, optimization, and automated code analysis would be simpler.
>>
>> 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?
>
<Excellent discussion of seperation of interface and implementation snipped>
Have you, by chance, ever used Sather? It was (I think development is
stopped) an Eiffel inspired language that seperated interface and
implementation inheritance (amoung several other cool ideas). Unfotunatly, I
never got to use it for any large projects, so never felt that I learned it well.
http://www.icsi.berkeley.edu/~sather/
--
Don Garrett http://www.bgb.cc/garrett/
BGB Consulting garrett at bgb.cc
More information about the Python-list
mailing list