Functional programming

Gregory Ewing greg.ewing at
Mon Mar 3 23:06:31 CET 2014

Steven D'Aprano wrote:
> Given that x is an integer, and that you add 1 (also an integer) to it, 
> is it really necessary to tell the compiler that add_one returns an 
> integer? What else could the output type be?

Just because the compiler *can* infer the return type
doesn't necessarily mean it *should*. When I was playing
around with functional languages, I ended up adopting the
practice of always declaring the types of my functions,
because it helps the *human* reader. (It also helped the
compiler produce comprehensible error messages in the
event of a type error.)


More information about the Python-list mailing list