Static typing (was Re: Java guy interested in Python)

Tim Peters tim.one at home.com
Sun Mar 11 02:11:22 EST 2001


[Hamish Lawson]
> ...
> Not sure that makes a type system? Isn't that what the modern
> understanding of a type is - a list of operations that are expected to
> be supported, as with Java's idea of interfaces being distinct from
> classes?
> ...

All type systems in all programming languages are hacks, because at heart
what you *really* want to say is "variable x must take on values from set S",
and interesting specifications for S may not even be computable.  So you
approximate in more-or-less crude ways, saying "i must be an int" when you
really mean "i must be an even integer" or "i must be an odd prime"; saying
"x and y must be reals" when you really mean "x and y must be reals such that
x**2 + y**2 <= 1"; etc.  A static type system is interesting to the extent
that it closely approximates what you want to say most often, and can be
efficiently checked at compile-time (there's nothing you can say in a static
type system that can't be said today at runtime in Python).

between-what-you-want-to-say-and-what-you-can-say-are-worlds-of-
    artificial-complexity-ly y'rs  - tim





More information about the Python-list mailing list