On 7/27/06, Chad Perrin <perrin / apotheon.com> wrote:
> On Thu, Jul 27, 2006 at 08:25:11AM +0900, Csaba Henk wrote:
> > On 2006-07-26, Sean O'Halpin <sean.ohalpin / gmail.com> wrote:
> > > implemented. For example, Ruby has real closures, Python doesn't. I
> >
> > Even if OT, just for the sake of correctness: let me remark that Python
> > does have closures. Local functions (ones defined within another
> > function's body) are scoped lexically.
> >
> > It's just sort of an anti-POLA (and inconvenient, as-is) piece of
> > semantics that variables get reinitalized upon assignment.
> >
> > Hence:
> >
> > def foo():
> >     x = 5
> >     def bar():
> >         x = 6
> >         return x
> >     bar()
> >     return x, bar
> >
> > x, bar = foo()
> > print x, bar() ==> 5 6
> >
> > def foo():
> >     _x = [5]
> >     def bar():
> >         _x[0] = 6
> >         return _x[0]
> >     bar()
> >     return _x[0], bar
> >
> > x, bar = foo()
> > print x, bar()  ==> 6 6
> >
>
> Is it just me, or are there no proper closures in that example code?
>

I've crossed my eyes twice and still can't see it ;)