Re: Delegating class methods
- From: Gary Wright <gwtmp01@xxxxxxx>
- Date: Mon, 2 Mar 2009 17:05:01 -0500
On Mar 2, 2009, at 9:24 AM, lasitha wrote:
There is a school of thought that eigenclass [1] instance variables
are generally preferred over @@class_variables. Folks coming to ruby
from other languages often miss the distinction but you'll find many
exposés on this [2], including in the Pickaxe.
I personally like eigenclass variables - they provide all the
capability of class variables, fit elegantly into ruby's object model
and follow all the rules of instance variables. So i don't ever bother
with class vars.
I don't think I've ever seen the term 'eigenclass variables' used in
this way. Every object has instance variables. Classes are objects
and so they have instance variables. There is no need to talk about
eigen classes (or the more common term, singleton classes) when you
are talking about alternatives to class variables.
The main confusion with Ruby class variables comes from:
-- Ruby class variables have syntax similar to instance variables
but much different semantics
-- Ruby class variables are assumed to be analogous to C++ class
variables (or Java class variables) but that is the wrong
analogy. Ruby instance variables of class objects is the more
appropriate comparison.
It would be nice if there was a common term for 'instance variables
of class objects' but 'eigenclass variables' isn't it.
Gary Wright
.
- Follow-Ups:
- Re: Delegating class methods
- From: lasitha
- Re: Delegating class methods
- From: Rick DeNatale
- Re: Delegating class methods
- References:
- Delegating class methods
- From: abc
- Re: Delegating class methods
- From: Albert Schlef
- Re: Delegating class methods
- From: Albert Schlef
- Re: Delegating class methods
- From: Leo
- Re: Delegating class methods
- From: abc
- Re: Delegating class methods
- From: lasitha
- Delegating class methods
- Prev by Date: Re: [ANN] wxRuby 2.0.0
- Next by Date: Sockets and Fedora Core 9
- Previous by thread: Re: Delegating class methods
- Next by thread: Re: Delegating class methods
- Index(es):
Relevant Pages
|