Confused about closures and scoping rules

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Wed Nov 7 05:52:13 EST 2007


Michele Simionato a écrit :
> On Nov 6, 7:37 pm, "Chris Mellon" <arka... at gmail.com> wrote:
>> On Nov 6, 2007 6:23 PM, Jean-Paul Calderone <exar... at divmod.com> wrote:
>>> Lots of people ask about this.  The behavior you observed is the expected
>>> (by the implementors, anyway) behavior.
>> Are there languages where closures *don't* behave like this? A closure
>> that used a copy of the state rather than the actual state itself
>> doesn't seem as useful. For references sake, JavaScript (the only
>> language that a) has closures and b) I have a handy way to test with)
>> does the same thing.
> 
> Closures in Haskell's list comprehensions work as Fernando (and many
> others would expect). 

IIRC, Haskell's 'variables' are constant (ie: you cannot rebind nor 
mutate them).



More information about the Python-list mailing list