[Python-ideas] Tweaking closures and lexical scoping to include the function being defined
Terry Reedy
tjreedy at udel.edu
Thu Sep 29 21:47:08 CEST 2011
On 9/29/2011 8:00 AM, Nick Coghlan wrote:
> It has in my mind. 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, anything directly in the argument list (even after **)
> would be inappropriate.
/'we'/'I and some of the discussants'/
It has occurred to me that one reason this threads is not getting
anywhere very fast is that there are two quite different proposals being
intermixed. People interested in and discussing the two different
proposals have been talking past each other.
One is to reproduce the behavior of defaulted parameters without having
the name appear in the signature to produce *read-only* private locals,
which amount to private define-time constants. This includes the int=int
type speed hack. I think '*, _int=int', with adjustment of
introspection, is sufficient. This make '_int' pragmatically constant,
while still externally over-rideable for exceptional purposes such as
testing or tracing.
The other is to introduce something new: private *read-write* closure
(persistent) name-value pairs. I agree that such a new thing should not
be in the param list between '(' and ')'.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list