From: Just Another Victim of the Ambient Morality Date: 2006-08-02T13:20:10+09:00 Subject: Re: I thought this was the one that worked? "Chad Perrin" wrote in message news:20060802024820.GB31291@apotheon.com... > On Wed, Aug 02, 2006 at 11:40:05AM +0900, Just Another Victim of the > Ambient Morality wrote: >> >> wrote in message >> news:Pine.LNX.4.64.0608012105530.19730@rubypal.com... >> > Hi -- >> > >> > On Wed, 2 Aug 2006, dblack@wobblini.net wrote: >> > >> >> Hi -- >> >> >> >> On Wed, 2 Aug 2006, Just Another Victim of the Ambient Morality wrote: >> >> >> >>> # this is the sample code you provided... >> >>> >> >>> a = 10 >> >>> # the block is defined here but "sent" to the "each" method... >> >>> [1, 2, 3].each {|x| puts x * a } >> >> >> >> I would say: control passes to the block. The block itself is not >> >> represented by an object (which I think is the only quasi-objective >> >> [ha ha] definition of "sent") in any scope other than the one in which >> >> it was created. >> > >> > (Nor, I should add, in the one in which it was created.) >> >> ...but does the definition of a closure require that the closure be >> an >> _object?_ No, a closure is a block of code that executes outside of it's >> defining scope but still has access to said scope. > > Someone correct me if I'm wrong, but . . . I got the impression that the > point being made didn't really have anything to do with objects, per se. > The use of the word "object" might have been ill-advised in terms of > keeping the conversation on-track. The impression I got from that is > that the intent was to say "the block itself is not represented, > present, whatever in any scope other than the one in which it was > created." The use of the term "object" probably arose only because > we're discussing closures within the context of Ruby. I know what you mean. I was afraid that he meant "object" in the colloquial sense, rather than the programmatic sense, except that he says "the block itself is not represented by an object," which is false if we interpret "object" in the general sense of the word. The keyword "yield" represents our ability to execute the block and we may even pass the block parameters with it. Therefore, I interpreted the use of the word "object" in the programmatic sense, since it is true that a method is not given a block as an object unless you explicitly convert it to one... > I think. I try to, as well, but it's hard sometimes...