Modifying func_closure

Robert Brewer fumanchu at amor.org
Sat Jul 10 14:23:25 EDT 2004


Talking about classes instead of closures, Terry Reedy wrote:
> This is the Python mechanism for getting the effect of 
> multiple functions accessing shared persistent but rebindable
> variables ('shared state' as Guido puts it).  Guido added
> read-only closures primarily, I believe, as a substitute
> for the default argument hack.  Notice that default args are
> also read-only, and that the change required no syntax change,
> merely either a legalization of previously illegal 
> (NameError-raising) code or a sematic change in having
> intermediate scope vars mask global or builtin vars.
> He had so far rejected sevaral proposals for adding syntax
> to make closures mutable, noting that classes already do
> mutable shared state (and perhaps also that one can instead
> use a mutable enclosed object).

Off-list, Jacek gave some reasons for preferring closures over classes.
Jacek, can I post them so we can discuss them further? Perhaps we could
revisit mutable closures.


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org




More information about the Python-list mailing list