[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Concerning "class instance variables"

Hal E. Fulton

3/17/2005 3:01:00 PM

Here's a slight reality check.

I'm probably largely responsible for the propagation of
the term "class instance variable." I didn't coin it, but
I used it in _The Ruby Way_.

It's not a totally bad term.

But let's remember that a class instance variable... is
really just an instance variable. It's just that the
object it belongs to happens to be a class.

This is confusing if you are used to languages such as
Java where classes aren't objects. In fact, when we say
that an instance variable "belongs to class Foo" in such
a language, we really mean that it belongs to _instances_
of class Foo.

In those languages, there is no distinction. In Ruby, there
is. A "class instance variable" is really just an instance
variable of a class, as opposed to an instance variable of
a non-class object.

In case that helps any.


Hal



1 Answer

Jim Weirich

3/17/2005 3:15:00 PM

0


Hal Fulton said:
> Here's a slight reality check.
>
> I'm probably largely responsible for the propagation of
> the term "class instance variable." I didn't coin it, but
> I used it in _The Ruby Way_.

I believe the term comes from Smalltalk, which has exactly the same
distinction between class variables and class instance variables (see
http://wiki.cs.uiuc.edu/VisualWorks/Class+variables+and+class+instance...).

--
-- Jim Weirich jim@weirichhouse.org http://onest...
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)