[Types-sig] type declaration syntax

Tim Peters tim_one@email.msn.com
Sun, 19 Dec 1999 23:51:04 -0500

> My bet is that the vast majority of Python people asking for
> "static typing" have in mind a conventional explicit system of
> the Algol/Pascal/C (APC) ilk, and that decisions based on what
> *inference* schemes can do are going to leave them very unhappy.

[John Skaller]
> I'm not sure why.

The rest of my msg went on at some length about why they would be unhappy;
I'm not going to repeat it here.  Or if the "why" is wrt why it's a
majority, you yourself recently wrote a very cogent piece on c.l.py
explaining that:  familiarity.  Relatively few Python programmers have any
experience with inference schemes; and the two on this SIG who have admitted
to it <wink> (that's Paul & me, BTW) testified they didn't really care for
it (I at least explicitly declare *every* function in Haskell, although I do
generally skip delcaring local names).

> My 'assumption' is that
> 	1) a conservative inferencer is used,
> which means it tries to optimise code by inference,
> but if it isn't sure, it falls back to the usual run-time
> checking -- that is, it faithfully reproduces the expected
> behaviour no matter what.
> 	2) optional static type declarations allow
> the performance of the inferencer to be improved;
> that is, to generate better code
> 	3) it would also help to tighten up
> the specifications of python, particularly
> in areas like
> 	a) when is it OK to expect an exception
> 	b) module freezing
> etc.

All of which are irrelevant to the points in the msg to which you're
replying.  People from APC are accustomed to declaring types to communicate
design requirements and semantic restrictions beyond the competence of
inference to determine.  If my first example was too subtle <wink>, at least
read the intgamma example.

> I would make the point that, as often is the case,
> the client is 'asking' for X, but what they actually
> need is Y, because they don't understand their own requirements.
> That is, they may be 'asking' for APC style static typing,
> but they have no idea what the implications are,
> and if they knew, they would withdraw their application.


> I guess that NO python programmer wants to declare the type
> of every single name, which is what APC style static type
> checking requires.

I would be delighted to if it sped some of my "marginal" programs by a
factor of 2.  My employer would be delighted to if it saved them from
runtime TypeErrors next week instead of next year.  Any tradeoff you can
think of has a larger audience than you can imagine <wink -- but that
includes an audience for Viperish global inference too!>.

repetitively y'rs  - tim