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

Rainer Deyke root at rainerdeyke.com
Sun Mar 11 11:56:00 EST 2001


"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.984294734.21888.python-list at python.org...
>
> 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).

When I type 'int i;' in C++, what I really mean is "'i' behaves like an
integer variable.".  I'm not saying anything about the values 'i' can take,
except that the values must support integer semantics.  The limited range of
type 'int' is part of its defined semantics, as is its fast performance.  If
I want to restrict 'i' to a subset of its possible values, I use an
assertion.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list