[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Class-level readers and writers

Christoph R.

11/29/2003 9:59:00 PM

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.

/Christoph


2 Answers

Gavin Sinclair

11/30/2003 1:50:00 AM

0

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.

Gavin


T. Onoma

11/30/2003 3:07:00 AM

0

On Saturday 29 November 2003 10:59 pm, 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''.

I'm not sure if I'm understanding this correctly. Is the following in any way
related:

ruby-core:01787
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby...

The short of it:

class X
a = 1
def a
@a # => 1
end
end

Or is that class local variable? Cause I'm not understand how @@a "will behave
like today's class instance variables without the need of ``class attribute
accessors''."

Can you elaborate more?

-t0