[Python-ideas] immutable classes [was: pre-PEP: Default Argument Expressions]

Jan Kanis jan.kanis at phil.uu.nl
Wed Feb 28 16:09:52 CET 2007


On Sun, 25 Feb 2007 23:45:08 +0100, Josiah Carlson <jcarlson at uci.edu>  
wrote:

>
> "Jan Kanis" <jan.kanis at phil.uu.nl> wrote:
>> On Tue, 20 Feb 2007 00:17:53 +0100, Josiah Carlson <jcarlson at uci.edu>
>> wrote:
>> > "Jan Kanis" <jan.kanis at phil.uu.nl> wrote:
>> >> <mode=dreaming> I just hope if
>> >> python were designed today it would have done these. </mode>
>> >
>> > Probably not.  Value binding breaks closures.
>>
>> That depends on how you exactly define closures. The basics of having an
>> inner function with free variables and initializing those free variables
>> to the values they have in the parent scope still works.
>
> It would break closures as defined for Python version 1.? to Python 2.5,
> Python 3.x, and beyond.
>
> Changing the semantics of Python closures is not the right thing to do,
> whether in 2.6, 3.x or otherwise.
>

Yup. That's why I used '<mode=dreaming>' and talked about if python were  
designed today, i.e. it didn't exist yet. Of course, that's not actually  
the case so it's a purely theoretical point.



More information about the Python-ideas mailing list