Modifying func_closure

Ville Vainio ville at spammers.com
Sat Jul 10 20:45:28 CEST 2004


>>>>> "Robert" == Robert Brewer <fumanchu at amor.org> writes:

    Robert> Talking about classes instead of closures, Terry Reedy wrote:

[ref. to Guido]

    >> 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).

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

Closures are indeed much handier than classes for many "in-place",
lightweight operations. Implementing a local class is often too
heavyweight, esp. if the creator has to implement __init__ as well as
another method that does useful work. Closures are well in line with
the "modern" way of Pythoning, up there with generators (that also
preserve state in local variables).

So yes, please, can we have our mutable closures now? The current way
of using them (having to "box" the mutatee in a one-element array) has
a hackish feel.

-- 
Ville Vainio   http://tinyurl.com/2prnb



More information about the Python-list mailing list