From: William Djaja Tjokroaminata Date: 2002-11-08T03:49:01+09:00 Subject: Re: Making Instace Variables Private/Local Yukihiro Matsumoto wrote: > Hi, > In message "Making Instace Variables Private/Local" > on 02/11/07, William Djaja Tjokroaminata writes: > |If you are still considering to use '@_var' or '@__var' to create class > |private/local variables, are you open to the idea of simply making all > |instance variables private? The descendant classes then can access the > |instance variables using 'self.var', where the method 'var' can either be > |public or protected. > I am not brave enough to introduce such incompatibility. I guess more > than 60% of Ruby programs will not run after such change. > matz. Hi Matz, I guess if you really introduce class local variables (@__var) then probably people can start migrating to using class local variables and child classes can start accessing parent's data using methods. But of course this boils down to your opinion, whether those 60% of Ruby programs are better off by migrating to internal data/interface separation. (In other words, whether you decide that it is perfectly fine that a child class accesses its parent class data directly in terms of '@var' and not 'self.var'.) (For me personally, rather than having the not-very-nice-looking @__var forever, it is probably better to have some transition period, just like things that are "deprecated", such as "type".) I am also wondering, among those people who wrote the 60% of Ruby programs, did it ever occur to any of them in the past an idea to provide data encapsulation/hiding/protection by accessing parent data using an interface (accessor method) instead of accessing the parent data directly? Regards, Bill