"Chad Perrin" <perrin / apotheon.com> wrote in message 
news:20060801075321.GE28188 / apotheon.com...
> On Tue, Aug 01, 2006 at 02:05:17PM +0900, Just Another Victim of the 
> Ambient Morality wrote:
>>
>
> [ snip ]
>
>>
>>     I _think_ I know what a closure is, as long as Wikipedia and all Ruby
>> tutorials haven't conspired to lie to me.  Again, it didn't occur to me 
>> show
>> you that they are closures.  I was only trying to show you what will make 
>> a
>> closure...
>>     So, are these closures, as you understand them?  How is your
>> understanding different from mine?
>
> There was some stuff to digest there, and I'll be digesting it.  As for
> what I didn't snip, I'll try explaining a closure (as I understand it)
> in different terms:
>
> There is a variable.  There is a (something we'll call "lambda").  The
> lambda uses the variable.  The variable is in a scope outside of the
> lambda's scope, but available to the lambda.  The variable's original
> scope "closes", thus eliminating the variable for purposes of anything
> else in the program other than the lambda, thus "closing" the code in
> the lambda -- thus the term "closure".  It produces circumstances that
> object oriented programmers would recognize as "protection" and
> "encapsulation".
>
> How does that mesh with your take on it?

    Well, I think that meshes just fine with my take on it...
    To tell you the truth, I didn't expect you to ask me what my 
understanding of a closure is because I thought I had already demonstrated 
it with the code sample I gave.  Of course, you're busy digesting that and I 
appreciate it.  It means you're actually trying to understand me (rather 
than just arguing at me.  Something that happens all too often...).
    If I may be so bold, I think that, perhaps, blocks don't look like 
closures to you because you don't realize that methods that take blocks, 
like "each," "inject," "collect," etc.. are methods (member functions, if 
you're a C++ guy) and not arbitrary language constructs, like "if," "while," 
"for," etc...

    Now that I think about it, this whole argument can be settled with one 
simple question.  If you doubt that all blocks are closures then show us a 
counter-example.  Show us a "block" that is not a closure and I will show 
you how it's not a block...