<div dir="ltr"><div>First, sorry for my (probably) bad english :)</div><div><br></div>I think that everyone who wants to learn about types, type system, what is static type, what is not, why function annotations (or some other, but I prefer it) refering to types is being proposed, should learn a little bit (you won't regret!)<div>
<br></div><div>1) This article (What to know before debating type systems) has been sent before in this thread (I think) but is a must read:</div><div><a href="http://cdsmith.wordpress.com/2011/01/09/an-old-article-i-wrote/">http://cdsmith.wordpress.com/2011/01/09/an-old-article-i-wrote/</a><br>
</div><div><br></div><div>2) Bob's talk in Europython last month "What can python learn from haskell" at least until minute 20, that talks about this things.</div><div><a href="http://pyvideo.org/video/3046/what-can-python-learn-from-haskell">http://pyvideo.org/video/3046/what-can-python-learn-from-haskell</a><br>
</div><div><br></div><div>3) If you love maths, some book of Benjamin C. Pierce (about type systems, of course!), this three are so good (but hard). Ordered from low to high level.</div><div>- Type Systems for programming languages.</div>
<div>- Types for programming languages.</div><div>- Advanced topics in Types and programming languages.</div><div><br></div><div>4) If want to learn more, search in google, there are so much books/articles about types, and if you can learn about haskell types (or Idris if you are crazy), better ;)</div>
<div><br></div><div><br></div><div>As last word, I want to give my opinion about the proposal.</div><div><br></div><div>I like the proposal, and I would love to see it in Python 3.x, I don't think that function notations can have a better purpose.</div>
<div><br></div><div>Of course, what is being proposed won't be needed to run a python program, and you will still can write your function notations whatever you want, but have a standard proposal will help a lot to build tools that read the function notations (like IDEs, linters, static type checkers, ...)</div>
<div><br></div><div>About the syntax, I love the mypy's syntax, and remember me a lot to other languages like scala.</div><div><br></div><div>def primes_to_n(n: Int) => List[Int] </div><div><br></div><div>def primes_to_n(n: int) -> List[int]</div>
<div><br></div><div><br></div><div>This two function definitions are a function that get an int and return a list of integers. First definition is Scala, second one is Python with mypy's syntax.</div><div><br></div><div>
I like much more the Haskell syntax, but is another world and I think that python shouldn't have a syntax like that:</div><div><br></div><div>primes_to_n :: Int -> [Int]</div><div><br></div><div>About other syntax that I had seen in this thread:</div>
<div>- decorators: I really don't like that one, is compatible with python 2, ok, but looks so bad (to me)</div><div>- docs: That's not bad at all, and can still exist with the typing syntax to declare the types, but we have function annotations where the types are much close to the definition, and that's definitively good.</div>
<div>- PyContracts: That's not bad at all, but just for check types in runtime, much things (the main diferences with mypy) can't be done in static, for example, how you know if this will work *before* execute it:</div>
<div><br></div><div>@contract</div><div>def f(x: 'list[3>](str)') -> 'list(str)'</div><div><br></div><div>f(input().split(" "))</div><div><br></div><div><br></div><div>That's a function that take a list of three or more strings, and is called with the user input.</div>
<div>You can't know if that list will be over three elements if you don't run it and get the input, and even those, you can't say that will be true all the times you execute it.</div><div><br></div><div><br></div>
<div>That's just my opinion :)</div><div><br></div><div>Cheers!</div><div><br></div><div class="gmail_extra">-- <br><div dir="ltr"><div style="text-align:center"><span style="color:rgb(51,51,51);font-family:Arial,Helvetica,sans-serif;line-height:16px">Miguel García Lafuente - Rock Neurotiko</span></div>
<div style="text-align:center"><span style="color:rgb(51,51,51);font-family:Arial,Helvetica,sans-serif;line-height:16px"><br></span></div><div style="text-align:center"><span style="color:rgb(51,51,51);font-family:Arial,Helvetica,sans-serif;line-height:16px">Do it, the devil is in the details.</span></div>
<div style="text-align:center"><font color="#333333" face="Arial, Helvetica, sans-serif"><span style="line-height:16px">The quieter you are, the more you are able to hear.</span></font></div><div style="text-align:center">
<span style="font-family:Helvetica,arial,verdana;font-size:15px;line-height:22.5px;text-align:left">Happy Coding. Code with Passion, Decode with Patience.</span><font color="#333333" face="Arial, Helvetica, sans-serif"><span style="line-height:16px"><br>
</span></font></div><div style="text-align:center">If we make consistent effort, based on proper education, we can change the world.<span style="color:rgb(51,51,51);font-family:Arial,Helvetica,sans-serif;line-height:16px"></span></div>
<div style="text-align:center"><span style="color:rgb(51,51,51);font-family:Arial,Helvetica,sans-serif;line-height:16px"><br></span></div><div style="text-align:center"><span style="color:rgb(51,51,51);font-family:Arial,Helvetica,sans-serif;line-height:16px">El contenido de este e-mail es privado, no se permite la revelacion del contenido de este e-mail a gente ajena a él.</span></div>
<div style="text-align:center"></div></div>
</div></div>