On Wed, Aug 02, 2006 at 05:07:41AM +0900, ara.t.howard / noaa.gov wrote:
> On Wed, 2 Aug 2006, Chad Perrin wrote:
> 
> >We're back to the absurdly broad here:
> >
> >If any "thing" that has access to another scope is a closure, that makes
> >every nested "thing" in a language with global and/or lexical scope a
> >"closure".  That's a little like defining a "human" as "has four limbs".
> 
> closures in ruby have neither global nor lexical scope though:
> 
>   harp:~ > cat a.rb
>   class Object
>     def closure(&b) b end
>   end
> 
>   c = closure
> 
>   def a() p 42 end
>   eval 'a', c
> 
>   def a() p 'forty-two' end
>   eval 'a', c
> 
>   harp:~ > ruby a.rb
>   42
>   "forty-two"
> 
> 
> the scoping is dynamic.  in otherwords we can add things to the enclosed 
> state
> later - it's not frozen at the time the closure is created.
> 
> that can refine the def a bit.

That's not much of a closure, then.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"The first rule of magic is simple. Don't waste your time waving your
hands and hopping when a rock or a club will do." - McCloctnick the Lucid