Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: Functional programming Date: Tue, 04 Mar 2014 11:06:31 +1300 Lines: 15 Message-ID: References: <4c7dbc57-eef9-4582-aecd-aac13a39b45f@googlegroups.com> <3b54a279-03a1-4a81-a428-ecad6eb16036@googlegroups.com> <216bb5f4-32c4-4f86-a9f4-1b0dd37a2a81@googlegroups.com> <0129a5b9-b85f-4ad5-b5e2-bfb2a48041d5@googlegroups.com> <5314bb96$0$29985$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net qu1nyLibaeQJpA2iSYMrAwzhzzlE3WxKyVvj+Opk1I3JM5jBPO Cancel-Lock: sha1:sU5ohzmNEncnz4vsNw3dfbosias= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: <5314bb96$0$29985$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:67594 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.) -- Greg