Next Functional Programming in Perl 16

Semantics of Python

 def mkcounter(a):
 def f():
 a = a + 1
 print a
 return f
 UnboundLocalError: local variable 'a' referenced before assignment
 def mkcounter(a):
 def f(a=a):
 a = a + 1
 print a
 return f

Closures aren't important.

--Guido van Rossum


Next Copyright 2005 M. J. Dominus

AltStyle によって変換されたページ (->オリジナル) /