From: Jacob Fugal Date: 2006-08-02T05:33:50+09:00 Subject: Re: I thought this was the one that worked? On 8/1/06, Chad Perrin wrote: > On Wed, Aug 02, 2006 at 05:07:33AM +0900, Jacob Fugal wrote: > > On 8/1/06, Chad Perrin wrote: > > >In any case, this can happen in Ruby: > > > > > > class Foo > > > def bar > > > lambda { puts "quux" } > > > end > > > end > > > > > > foo = Foo.new > > > bar = foo.bar > > > > > > bar.call > > > > > >. . . so I don't see your point. Cut out the middleman, and it still > > >works. > > > > Ah, but you're still using self in that example. Who is the receiver > > of the call to puts inside the block? It's self. > > That's an impressive bit of gymnastics. Gymnastics? What exactly did I twist? > I don't buy it as satisfying > the requirements of a closure, though, at this point. Self is just > something within the current scope, and we're back to an absurdly broad > redefinition of "closure". What current scope are you referring to here? If you mean the scope that was current when the block was created, then why does that not make it a closure? Why is self different than some other variable named b? If you don't mean the scope that was current when the block was created, then you're mistaken, because it *is* the self that was current when the block was created that is used. This is what others were trying to demonstrate in the examples you dismissed as having irrelevant variables. > > There is no such thing as a "function" in ruby; they are all methods. > > Methods are "functions" in the technical, broadly interpreted computer > science definition of the term. They're just a special case of > "function" that requires more specific conditions to qualify as > "methods". A method is a function: a function is not necessarily a > method. Ok, we're using different definitions of function. That's why I put function in quotes when I said it, but I can see you want to be pedantic. By your definition, a method is indeed a function. But I counter your last statement: in Ruby, all functions are necessarily methods, because you can't call a method/function without a receiver. You can write it syntactically without a receiver, but in that case a receiver of self is still implicit. In this sense, Ruby has no "functions", only methods. Jacob Fugal