News for hackers. Stuff that matters.
Re:Introducing Closure Tools by andreyf on Thursday November 05, 2009 @06:56PM (#925099)
A closure is just a (function, bindings) pair, so Python certainly has closures. The problem with Python is that there is no syntax for assigning to variables declared in an arbitrary scope, because there are no explicit declarations. As far as I understand, implicit local variables are what causes the problems in Python, not anything about closures, really. This causes other problems, too, such as those PG described here [1], under the heading "Implicit local variables conflict with macros".

1. http://www.paulgraham.com/arclessons.html

Re:Introducing Closure Tools by micheles on Friday November 06, 2009 @09:48AM (#926023)
Python 3 has read-write closures. Check out the nonlocal declaration.
Re:Introducing Closure Tools by andreyf on Friday November 06, 2009 @02:20PM (#926693)
The nonlocal statement causes the listed identifiers to refer to previously bound variables in the nearest enclosing scope. [1]

While certainly a big improvement, we still can't access variables in arbitrary scopes, just local, nearest non-local, and global. To me, this seems a significantly more complex way of specifying variable scope than just declaring it explicitly.

1. http://docs.python.org/dev/3.0/reference/simple_stmts.html#t...

Re:Introducing Closure Tools by mjs on Friday November 06, 2009 @03:26AM (#925683)
Interesting. Thanks.