Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

On Mon, Apr 20, 2015 at 12:51 PM, Nikolaus Rath <Nikolaus@rath.org> wrote:
Jukka (mypy's author) believes that specifying full annotations will catch more bugs, and makes the error messages easier to understand -- in practice when you let the type inferencer run free it will often infer bizarre union types or other complex forms, and the errors may well appear in the wrong spot. This is a common issue with type inferencing, and anyone who has tried to learn Haskell (or C++ :-) has plenty of experience with such errors. The good news is that I don't actually expect people to have to write or even read stuff like the above; the example was quoted out of context. In code that the typical (mediocre :-) programmer writes, argument types won't be more complex than some built-in primitive type (e.g. int or str) or a List of primitive types, or perhaps a user-defined class or List of such. And you can always leave the annotation out if you find yourself fighting the type checker -- it will default to Any and the type checker will just shut up. That's the beauty of gradual typing (and it differs greatly from strict typing as seen in Haskell or C++). -- --Guido van Rossum (python.org/~guido)
participants (1)
-
Guido van Rossum