Hi --
Nice article, but I disagree in the point that @@vars are simpler than class instance variables. Class instance variables have odd semantics in the current Ruby which means that they will probably do some detail different than you expect.
But you have to do:
class Foo
@var1 =
@var2 = {}
class << self
attr_accessor :var1, :var2
end
endto get reasonable access to those class instance variables inside an instance method, and even then you have to do self.class.var1
Once you 'get it' it's not TERRIBLY difficult, but I would say that the above is more than enough justification for calling @@foo simpler. Simpler, but also confusing in the inherited-class cases.
Also, they're different. In 2.0, it sounds like they will be more
similar to each other, because class vars will be truly scoped per
class. I'm not in favor of that. Class variables, in my view, are
responsible already for a huge amount of misunderstanding of
*instance* variables (because the @/@@ thing always makes people think
there must be some connection or similarity between the two entities,
and then they get confused when there isn't).
I'm not sure what the best thing would be. I tend to root for the
removal of class variables entirely. I might even be able to tolerate
#class_attr_* methods, which actually make no sense (since there's
really no more reason to create special methods, in that area, for
Class objects than any other object) but might keep things smoother.
David
···
On Mon, 18 Apr 2005, Gavin Kistner wrote:
On Apr 18, 2005, at 6:33 AM, Florian Groß wrote:
--
David A. Black
dblack@wobblini.net