From: Chad Perrin Date: 2006-08-02T04:10:21+09:00 Subject: Re: I thought this was the one that worked? On Tue, Aug 01, 2006 at 10:20:06PM +0900, Just Another Victim of the Ambient Morality wrote: > "Chad Perrin" wrote in message > > > > 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: I don't. A closure is a closure whether you use it or not, just as a remote control for the TV is a remote control for the TV whether you use it or not. What's actually relevant to the discussion is more like the question of whether a remote control for the TV is still a remote control for the TV if it was built with no TV on which it could operate. > > 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 Actually . . . no. If that was a closure just because there was a variable nearby that it could access, then in any script that contains a lexical variable at the "base level" of the script, and in any script that has global variables, every scope enclosed within the scope of the script would be a closure. > > > 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... Unfortunately, it was David and possibly one or two others who have been instrumental in narrowing it down. You're still talking about things that don't seem to bear on what I was saying at all. > > 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... Not to be insulting, but I don't think you've grasped the fact that there's more to being a closure than being a language construct that someone once said was a closure. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] unix virus: If you're using a unixlike OS, please forward this to 20 others and erase your system partition.