On Mar 22, 2011, at 1:23 AM, John Mair wrote:

>> One thing that you emphasized and which is confusing is that the
>> singleton class notation:
>> 
>> class <<object
>> end
>> 
>> does *not* create a new lexical scope - nor does class_eval or
>> instance_eval.
>> 
> 
> No, it *does* create a new lexical scope -- did you test it ? :)
> 
> o = Object.new
> j = 10
> 
> class << o
>  puts j
> end

I think it was my sloppy terminology that was confusing.  My intent was that the phrase 'lexical scope' would refer to the scope that was relevant to constant and class variable resolution.  As you've pointed out, that phrase just is not specific enough as there is a lexical scope created for local variables by the singleton class notation (and blocks).  So there are at least two different types of lexical scopes that affect name resolution of variables and constants.  I'm not sure if there is any standard terminology used to differentiate them.  Perhaps that is part of the confusion.

Gary Wright