does lack of type declarations make Python unsafe?

Donn Cave donn at drizzle.com
Fri Jun 20 00:55:55 EDT 2003


Quoth "Greg Ewing (using news.cis.dfn.de)" <g2h5dqi002 at sneakemail.com>:
| David Abrahams wrote:
|> I don't have any first-hand experience, but the experience of friends
|> of mine who have used Haskell is that it can be exceedingly difficult
|> to locate the source of a type error when it does occur, since the
|> inference engine may propagate the "wrong" type back much further than
|> the source of the error.
|
| I played with HUGS intensively for a while some time back,
| and I can attest that this is indeed a problem. I was led
| to the conclusion that the only way to retain my sanity
| was to provide an explicit type declaration for every
| function.
|
| This has two benefits -- it helps the compiler catch
| type errors early enough to actually give you a useful
| error message, and it helps to document the code.
|
| But if you're doing that, you don't get much benefit
| from type inference, raising the question of whether it's
| worth the effort of designing a compiler that can do it
| at all.

There's a huge difference between optional type annotation
and a system that requires you to declare the type of every
single thing.  The latter is a big nuisance, and far from
helping to document the code it buries the sense of what the
function is doing in a lot of trivia about its parts.

	Donn Cave, donn at drizzle.com




More information about the Python-list mailing list