[Python-ideas] Structural type checking for PEP 484
Sven R. Kunze
srkunze at mail.de
Thu Sep 17 23:42:52 CEST 2015
On 17.09.2015 07:56, Andrew Barnert wrote:
> I'm not sure which problems you want solved.
> If you want every type to be inferable, for a language with a sufficiently powerful type system, that's provably equivalent to the halting problem, so it's not going to happen.
Nobody said it must be perfect. It just needs to be good enough.
> More importantly, we already have languages with a powerful static type system and a great inference engine, and experience with those languages shows that it's often useful to annotate some types for readability that the inference engine could have figured out. If a particular function is more understandable to the reader when it declared its parameter types, I can't imagine what research anyone would do that would cause me to stop wanting to declaring those types.
Because it's more code, redundant, needs to me maintained and so on and
> Also, even when you want to rely on inference, you still want the types to have meaningful names that you can read, and could have figured out how to construct on your own, for things like error messages, debuggers, and reflective code. So, the work that Jukka is proposing would still be worth doing even if we had perfect inference.
I totally agree (and I said this before).
Speaking of meaningful names, which name(s) are debuggers supposed to
show when there is a multitude of protocols that would fit?
>> Btw. I can tell the same anecdote when switching from C/C++/C#/Java to Python. It was like a liberation---no explicit type declarations anymore. I was baffled and frightened the first week using it. But I love it now and I don't want to give that freedom up. Maybe, that's why I am reluctant to use it in production.
> The problem here is that you're coming from C++/C#/Java, which are terrible examples of static typing. Disliking static typing because of Java is like disliking dynamic typing because of Tcl. I won't get into details of why they're so bad, but: if you don't have the time to learn you a Haskell for great good, you can probably at least pick up Boo in an hour or so, to at least see what static typing is like with inference by default and annotations only when needed in a very pythonesque languages, and that will give you half the answer.
I came across Haskell quite some time ago and I have to admit it feels
not natural but for other reasons than its typing system and inference.
More information about the Python-ideas