On Thursday, October 10, 2013 6:51:21 AM UTC-7, Tim wrote:
> I've read a couple of articles about this, but still not sure.
> 
> When someone talks about a closure in another language (I'm learning Lua on 
> the side), is that the same concept as a decorator in Python?
> 
> 
> 
> It sure looks like it.
> 
> thanks,
> 
> --Tim

In the proper lambda calculus, you don't have side effects. So Terry's balance 
example is helpful for Python, but perhaps it might be better think of it as a 
Pythonic extension to the lambda calculus closure. In other words, Python's 
closure handles cases that don't present themselves in the lambda calculus.

When you are taught about closures in a purely formal setting the example will 
not include a side effect nor any need for a statement like "nonlocal balance". 
The closed variable (here it is balance) simply remains part of the scope of 
the inner function and can referenced appropriately. 

This might distract the original questioner, I only mention that "closure" 
probably means different things to different people.
 

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to