3 ms·
Not really. For one thing, you can't modify the closed over values unless you manually box them in a list, due to scope ambiguity. (This may be fixed in 3.0.) I
by silentbicycle 17y ago
Not really. For one thing, you can't modify the closed over values unless you manually box them in a list, due to scope ambiguity. (This may be fixed in 3.0.) It's a little thing, but it makes code that depends on manipulating closures pretty ugly, discouraging their use.
Scheme avoids the issue by having a non-ambiguous syntax (a big advantage of those parens), and Lua avoids it by defaulting to global scope* unless you declare them with "local", which also anchors their scope unambiguously.
* Which is actually not a big deal - the global table is just another table, so you can hook its set method to catch unexpected globals (see strict.lua). It's far less trouble than Python's solution.
- kingkilr 17y agoPython 3.0 introduces the nonlocal keyword which allows you to assign to closed over names.