From: Eric Hodel Date: 2006-12-07T04:50:55+09:00 Subject: Re: Unexpected scope range On Dec 5, 2006, at 18:40 , Paul Lutus wrote: > Eric Hodel wrote: > > / ... > >> There is no such thing as a "class instance variable" in Ruby. > > Assertion 1. > >> Classes are real objects too, and they have "instance variables" just >> like everybody else. > > Assertion 2 appears to contradict assertion 1. > > Strictly speaking, this is about classes, only peripherally about > Ruby, and > Ruby shouldn't deviate from the general terminology used to describe > classes and their aspects. I'm sorry if you've spent your time trapped in crappy OO languages like Java and C++ where classes aren't real objects. > If you want assert that there is such a thing as a class instance > variable > that is global to all members of the class ... hey, go for it. I > find it > confusing, reasonable people will differ. > > IMHO, classes _have_ instances, but classes are not themselves > instances. ruby disagrees with your opinion: ruby -e 'p Object.class; p Object.ancestors' Class [Object, Kernel] As does "ri Class". > Objects created using class constructors are instances of that class. > > I don't normally do this (it comes off as an empty appeal to > authority), but > please look at page 388 of the Pickaxe book, under the heading "class > instance variables". The discussion is about what you have been > calling > instance variables, and I have been calling ... class instance > variables. What the pickaxe refers to as "class instance variables" are "instance variables of a Class". There is no difference in instance variables no matter which object they live in. Clinging futilely to some believe that there is some difference will only limit your understanding of Ruby. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net I LIT YOUR GEM ON FIRE!