On Sunday 23 November 2003 10:04 pm, Mauricio Fern?ndez wrote: > On Mon, Nov 24, 2003 at 05:32:09AM +0900, Mathieu Bouchard wrote: > > I think the actual problem would be more with code that does things like > > this: > > > > def foo(n) > > (0...n).map { > > proc {a=0; proc{a+=1;a}}[] > > } > > end > > This would work with the new rules (and the current ones), I believe: > > def foo(n) > (0...n).map { proc {|a| proc{ a += 1; a } }[0] } > end > > > I expect this code to produce n distinct counters that will each produce > > their own independent sequence 1,2,3,4,5,... when called repeatedly. If > > it becomes impossible to do this anymore, then I won't be able to > > honestly say that Ruby really supports closures. > > It won't be impossible, just inconvenient. actually using foo(3).each { |q| p q.call } they both produce 1 1 1 but in both, if you add a=0: def foo(n) a = 0 (0...n).map { proc {|a| proc{ a += 1; a } }[0] } end then 1 2 3 So you tell me how it changes in new system, cause I don't know. i'm guessing the first won't be 1 1 1 anymore. but who am i to say? i find the examples confusing enough in themselves :). -t0