[Python-ideas] Tweaking closures and lexical scoping to include the function being defined
Jim Jewett
jimjjewett at gmail.com
Fri Sep 30 17:02:36 CEST 2011
On Thu, Sep 29, 2011 at 5:24 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Nick Coghlan wrote:
>> As Guido noted, default argument *names* refer to
>> ordinary locals, and hence exhibit the same rebinding behaviour as
>> pre-nonlocal closure references (i.e. reassignments don't persist
>> across calls, only mutations do). Since we expressly *don't* want that
>> behaviour,
> Are you sure we don't? The ability to persistently re-assign
> the name is not needed to address the main use cases under
> consideration, as I understand them to be. In fact, disallowing
> assignment to the name at all would be fine by me. Hence I
> would be +0 on using 'const' as the keyword.
What do you think the main use cases are?
If you can't rebind, it obviously doesn't solve the Counter case.
As best I can tell, const only works for speed hacks. And there are
other ways to solve that, if you're willing to use a different VM,
like pypy does.
-jJ
More information about the Python-ideas
mailing list