in the book Graham says about closure :
"""When a function refers to a variable defined outside it, it's called a free variable. A function that refers to a free lexical variable is called a closure The variable must persist as long as the function does."""
and after says also that """Closures are one of the uniquely wonderful things about Lisp"""...but isn't it?
for example in python we can follow this behavior for example with 'nonlocal' variabile declaration:
Code: Select all
def closurep():
n = 3
def closurep_help(m):
nonlocal n # now we can set a new value for 'n
n += 1
return (n * m)
return closurep_help
x = closurep()
print(x(3)) --> 12
but also decorators may be considered in "closure way"...if we want..
then I understood the true meaning of CLisp closure? are they only a CL 's prerogative?.. thanks in advance