From: Chad Perrin Date: 2006-08-02T11:49:23+09:00 Subject: Re: I thought this was the one that worked? 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 think. On the other hand, I think "a block of code that executes outside of its defining scope but still has access to said scope" works as about a 90%-complete definition of closures. All that's really missing is something that seems to be necessarily implied by that sentence: that the scope in question is "closed". -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] "Real ugliness is not harsh-looking syntax, but having to build programs out of the wrong concepts." - Paul Graham