[Types-sig] Why I don't like static types in Python

Tim Peters tim_one@email.msn.com
Sun, 29 Nov 1998 18:12:31 -0500


[Tim]
> Ahem -- functional languages deliberately constrain their
> type systems to make type inference tractable.  Python doesn't.

[Bill Tutt]
> Well, Self had a type infrencing engine written for it, and its
> argubably as dynamic, or more dynamic than Python.

I'm in a foul mood today.  This is comparing apples to dog saliva.
Functional languages are deliberately designed to make type inference
reasonably efficient and straightforward.  Coming up with a type inference
system for a language that isn't so designed remains a PhD-level research
task:

> ...
> Ole Agesen's Ph.D. thesis
> (http://www.sunlabs.com/technical-reports/1996/abstract-52.html)
> "Concrete Type Inferencing: Delivering Object-Oriented Applications".

Which, among other things, contains a good discussion of the Hindley-Milner
flavor of inferencing, and why that's not good enough for Self (the
connection to the above is that functional languages are designed to play
nice with Hindley-Milner specifically:  design the language to fit the slick
algorithms).

It took Ole Agesen 187 pages to sketch what he did for Self.  That's about
182 pages more than anyone is likely to have time to implement for Python
<0.9 wink>.

> However several factors make type infrencing Python fairly difficult:
> 	Type infrencing is best used in a closed environment. (akin to
>         using freeze)
> 	The type infrencing system also benefits greatly from having
>         detailed type signatures of C extensions.

For another take on the subject, see Ken Walker's "The Implementation of an
Optimizing Compiler for Icon" (Doctoral Dissertation, The University of
Arizona, July 1991).  That seems hard to get now, but an extended summary of
the type inferencing portion of it can be gotten as the later paper "Type
Inference in the Icon Programming Language", by Kenneth Walker and Ralph E.
Griswold, from

    ftp://ftp.cs.arizona.edu/icon/doc/tr93_32.pdf

> Which isn't to say it isn't possible, it is, its just complex and time
> consuming to implement.
> Anybody need a masters thesis topic? ;)

It's still PhD-level stuff -- and unlike Self or Icon, Python isn't run by a
tenured professor with hordes of doctoral-candidate full-time slave labor.

although-jimh-often-does-a-credible-impersonation<wink>-ly y'rs  - tim