>> (2) If I do the following
>>       class F
>>       end
>>       f = F.new
>>       F.class  # class
>>       f.class  # F
>> this makes sense to me.
>> 
>> What (relevant and important conceptually) messages (other than "new")
>> can I send to a class?  

MLK> See the documentation for class Class.

>> But see (3), below.
>> 
>> 
>> 
>> (3)
>>     class F
>>       def sub1
>>         @@x = 1
>>       end
>>     end
>> 
>>     class G
>>       self.sub1
>>         @@x=2
>>       end
>>     end
>> 
>>     # Why?  Didn't the interpreter "see" @@x in class F?
>>     F.class_variables  # []

MLK> Probably not, since you haven't called the function yet!

Didn't the interpreter parse it?

If I do
  class X
    def y
      xyzzy = 3++
    end
  end

then the interpreter/parser will complain immediately that there was a
syntax error even though the function method y was not executed.

>> 
>>     # makes sense
>>     G.class_variables  # ["@@x"]

MLK> I'm actually rather surprised by this.

I made a mistake.  I apologize.
  class G
    def self.sub1
      @@x=2
    end
  end

G.class_variables # []

(I must have run the function accidentally.  Sorry.)

>> 
>>     f = F.new
>> 
>>     # Why?  Shouldn't the method inherit from the class?
>>     f.class_variables  # undefined method

MLK> No!  class_variables is a class method of F.  Instances do not get 
MLK> access to their class' class methods, because they don't inherit from 
MLK> the Class object in the conventional sense.  The Class object is a 
MLK> little bit like a JavaScript prototype, if that helps.

MLK> If it doesn't...well, I don't know what to say.  If you're really as 
MLK> good a C++ programmer as you claim to be, then you should be having no
MLK> trouble at all with the difference between class and instance methods.

In C++, instances have access to the static variables and functions of
the class.

They don't inherit it ... but merely have access to it as if they
inherited it.

>> 
>>     f.sub1  # 1
>> 
>>     # makes sense.  class variable now explicitly executed
>>     F.class_variables # ["@@x"]
>> 
>>     # How to use class_variable_get if the method is private???
>>     F.class_variable_get(:@@x)  # error private method!
>> 

MLK> Just don't.  You're not meant to be getting at class variables from 
MLK> outside the class.  Use an accessor function if you need it.

MLK> (There is a way to call private methods from outside, but I will leave
MLK> you to find it out on your own.  It's not generally a good thing, and 
MLK> I'm not going to hand you a dangerous tool until you understand when not
MLK> to use it.)

So ... when _can_ I use class_variable_get  ???