does lack of type declarations make Python unsafe?

Greg Ewing (using news.cis.dfn.de) g2h5dqi002 at sneakemail.com
Thu Jun 19 00:50:52 EDT 2003


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.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list