does lack of type declarations make Python unsafe?

David Abrahams dave at boost-consulting.com
Fri Jun 20 10:07:31 EDT 2003


"Donn Cave" <donn at drizzle.com> writes:

> 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.

Clearly that's a matter of opinion.  I'd love to use a language which
made type inference optional, just to see.  Maybe I'll have to start
playing with Haskell.

In the meantime, I'd like to quote a favorite phrase:

   "Explicit is better than implicit"

<wink>

turning-the-zen-against-itself-ly y'rs,
Dave

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Python-list mailing list