From: Logan Capaldo Date: 2006-08-01T21:12:18+09:00 Subject: Re: I thought this was the one that worked? On Aug 1, 2006, at 6:39 AM, Chad Perrin wrote: > 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? > > >> >> Personally, I would call them closures, if they have access to >> their >> environments. >> Perhaps we can agree to call a closure a block of code that >> has the >> _ability_ to access variables of their enclosing scope, rather >> than strictly >> requiring that they take advantage of this ability? > > Not yet. See above, re: blocks falling in a forest. > > 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. > > 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. > > -- > CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] > This sig for rent: a Signify v1.14 production from http:// > www.debian.org/ > More examples to chew on: class A def make_closurish_thing lambda { puts "Hello" } end end a = A.new c = a.make_closurish_thing c.call def a.puts(*args) super("Access of enclosing scope") super end c.call class B def close_me x = 1 lambda{|x| eval(x) } end end b = B.new c = b.close_me c.call("puts 'Am I a closure?'") c.call("puts 'How about now?'; puts x")