On Jul 31, 2006, at 3:30 PM, Chad Perrin wrote:

> On Tue, Aug 01, 2006 at 04:23:27AM +0900, Logan Capaldo wrote:
>>
>> repeat is a local variable. class, def, and module introduce a new
>> scope without closing over their enclosing scope. Blocks introduce a
>> new scope that does enclose it's enclosing scope.
>
> As I understand it, this means that class, def, and module use dynamic
> local scope, and blocks use static/lexical scope.  Is that accurate?
>
All these examples are lexical scoping. Ruby doesn't really have  
dynamic scoping although you can sort of abuse instance variables to  
achieve similar effects.

The difference is that blocks are closures, where def, class, and  
module aren't.



> -- 
> CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
> "Real ugliness is not harsh-looking syntax, but having to
> build programs out of the wrong concepts." - Paul Graham
>