Trans wrote:

>This still avoids a solution to closing scope for other uses. For
>instance Class.new.
>
>  A = Class.new {
>    class B
>      def x; 1; end
>    end
>  }
>
>  A::B
>  (irb):19: warning: toplevel constant B referenced by A::B
>  
>
Ho. That is wacky. Same thing for normal constants and for class 
variables, of course, 'cept no warning for class variables.

class A
  def self.B
    Class.new {
      @@share = "hello!"
    }
  end
end
B = A.B
p B.class_eval { @@share }  #=> error, uninitialized? wha?
A.class_eval { @@share = 'duck' }
p B.class_eval { @@share } #=> "duck"

You can actually just do Class.new and get the class-variable-sharing 
thing -- I just stuffed the block in there 'cause I'm wondering about 
the uninitialized part.

C:\Documents and Settings\dlm>irb
irb(main):001:0> Class.new {
irb(main):002:1*   @@share =  'hello' }
=> #<Class:0x2cff5a0>
irb(main):003:0> @@share
=> "hello"
irb(main):004:0>

C:\Documents and Settings\dlm>irb
irb(main):001:0> class A
irb(main):002:1>   B = Class.new { @@share = 'hello' }
irb(main):003:1> end
=> A::B
irb(main):004:0> A.class_eval { @@share }
NameError: uninitialized class variable @@share in Object
        from (irb):4
        from (irb):4:in `class_eval'
        from (irb):4:in `class_eval'
        from (irb):4
irb(main):005:0> A::B.class_eval { @@share }
NameError: uninitialized class variable @@share in Object
        from (irb):5
        from (irb):5:in `class_eval'
        from (irb):5:in `class_eval'
        from (irb):5

Wha???

Devin