From: Keith Gaughan Date: 2006-07-27T08:53:18+09:00 Subject: Re: For performance, write it in C On Thu, Jul 27, 2006 at 08:33:31AM +0900, Chad Perrin wrote: > On Thu, Jul 27, 2006 at 08:25:11AM +0900, Csaba Henk wrote: > > On 2006-07-26, Sean O'Halpin 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? No, Chad. There's closures in there. What you're not seeing is anonymous functions, but closures are not the same as anonymous functions. -- Keith Gaughan - kmgaughan@eircom.net - http://talideon.com/