From: "David A. Black" Date: 2003-11-30T11:29:14+09:00 Subject: Re: Class-level readers and writers Hi -- On Sun, 30 Nov 2003, Gavin Sinclair wrote: > On Sunday, November 30, 2003, 8:59:15 AM, Christoph wrote: > > > David A. Black wrote: > > ... > >> So that's probably not a great idea in most cases. Class > >> variables have their own quirks, though they're scheduled to > >> be a bit de-quirked in 2.0. > > > My understanding (not that my record in reading Matz 2.0 > > intention is anything I should be bragging about - not that > > I mind, since I am feeling like a kid in a candy store:-) > > was that Rite's class variables will behave like today's class > > instance variables without the need of ``class attribute > > accessors''. > > > Personally I am actually in favor of getting ride of class variables > > altogether and only use class attributes accessors + class instance > > variables. > > I sympathise. Maybe @@x could be syntax sugar for > self.class.instance_eval("@x"), if you get my drift. > > class Example > @x = 5 > > def meth > @@x # -> 5 > end > end > > There's probably a really good reason why not; I've never really been > able to wrap my head around all the issue here. That would create a situation where it was awfully easy for one object to get at another object's instance variables, without the second object having granted access. It's already possible, as your example shows, but I don't think it's the kind of thing one would want to encourage with shortcuts (unless the object itself creates them). I think the new incarnation of class variables might be handier than [I've found] the current one [to be], though sometimes I also wish they'd just disappear :-) I think part of the trouble people have with the concept of Class objects having instance variables is that they (wrongly but understandably) surmise that there must be some relation or connection with class variables. David -- David A. Black dblack@wobblini.net