Functional programming
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Mar 4 10:45:51 EST 2014
On Wed, 05 Mar 2014 02:28:17 +1100, Chris Angelico wrote:
> On Wed, Mar 5, 2014 at 2:18 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> You don't need to have static typing to have declared variables. The
>> two are independent. E.g. one might have a system like Python, except
>> you have to declare your variables before using them:
>>
>> global x
>> local a
>> a = x+1
>
> Aside: If you declare your locals, you shouldn't need to declare your
> globals. Though I could imagine a rule that global rebinding still needs
> to be declared, but you certainly shouldn't need to declare nonlocal if
> you have a local declaration. Absence of local => nonlocal.
You missed that the purpose of the declaration is to avoid accidental
typos:
local process
procces = 1234
With declarations, the compiler can catch some typos at compile-time.
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list