From: Just Another Victim of the Ambient Morality Date: 2006-08-01T22:20:06+09:00 Subject: Re: I thought this was the one that worked? "Chad Perrin" wrote in message news:20060801103834.GB28710@apotheon.com... > On Tue, Aug 01, 2006 at 06:50:09PM +0900, Just Another Victim of the > Ambient Morality wrote: >> >> This seriously sounds like an "if a tree falls in the forest, does it >> make a sound?" kind of situation. In other words, it's a semantic >> argument... > > Okay, let's translate that question into the terms we're actually > discussing. > > 1. If a tree falls in the forest, and there's no one around to hear > it, does it still make a sound? > > 2. If a lambda has the ability to access its context, but there isn't > any context to access, is it still a closure? How about this: 3. If a lambda has the ability to access its context and nothing's around to use it, does it still make a closure? I think 3 is a better characterization than 2. Here's some code to demonstrate: variable = 2 # this is the context [1, 2, 3].each do |i| # it sounds as if you think this is the "context" puts i + variable # either way, we're using the context so # we agree that this is a closure end [4, 5, 6].each do |i| # a context exists here since we # have access to "variable" puts i # but we don't use it. # are we still a closure? end > I'm beginning to think the question of whether it's actually a closure > really IS a question for a programming koan, after all. If so, I'm glad > we've at least narrowed the discussion down to this point at last. I agree that we have finally narrowed down the discussion. This might have happened sooner if I had actually followed the thread... > It'd be pretty neat to be responsible for the creation of a new > programming koan, anyway. I'm going to go add this to my sig rotation > right now. Ah, it's over-rated... Is a loop a loop if it only loops once? Does a parameter exist if we don't actually access it? Not to be insulting but there's a part of me that thinks that you came up with this distinction to hide the (embarrassing?) fact that you didn't know that all blocks were closures...