Confused about closures and scoping rules

Michele Simionato michele.simionato at gmail.com
Tue Nov 6 22:47:19 EST 2007


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). See for instance this post:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/d691240a5cfebcdf/63234494ebbca54e?hl=en&lnk=gst&q=simionato+haskell#63234494ebbca54e


   Michele Simionato




More information about the Python-list mailing list