From: Chad Perrin Date: 2006-07-27T08:33:31+09:00 Subject: Re: For performance, write it in C 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? -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] print substr("Just another Perl hacker", 0, -2);