Python Type-Inference based LINT.. (pylint.py)

Greg Ewing greg.ewing at compaq.com
Wed Nov 24 11:54:10 CET 1999


Martijn Faassen wrote:
> 
> Note that this doesn't need to be a syntax extension; check out some of
> my Swallow posting with dejanews for examples of how it could work in
> current Python.

I think I'd prefer it if it *were* a syntax extension.
The suggestions I've seen so far for non-syntax-extending
type declarations strike me as rather ugly.

That's a minor point, though -- the main thing is to
get some sort of type checker to work! The syntax can
be thrashed out later.

> I myself would take the Python subset approach
> (i.e. Swallow) to make sure no runtime dynamics exist that can mess up
> any type checking. Seems to me the easier approach

Me, too. Also, I tend to think that explicit type
declarations are a valuable way for the programmer to
state the *intent* of the code in a way that both
humans and compilers can process. In my experience,
type errors are found sooner and reported in a more
easily understood way when explicit type declarations
are used.

I've tried it both ways when using Haskell-like
languages, and I find that the error messages I get
when I don't explicitly declare types tend to be of
the form

   Couldn't unify <some-big-hairy-complicated-type-
   expression> with <some-other-big-hairy-complicated-
   type-expression-that-looks-vaguely-similar-although-
   there-must-be-some-subtle-difference-if-only-I-can-
   find-it>.

After getting a few of those I quickly learned to
provide type declarations for ALL my functions...

Greg




More information about the Python-list mailing list