From: dblack@... Date: 2002-08-12T22:27:54+09:00 Subject: Re: ambiguity backtrack - accessors and persistent locals Hi -- On Mon, 12 Aug 2002, Tom Sawyer wrote: > i'd like to refocus on this aspect of the ambiguity thread. from what's > been posted thus far on the topic, it would seem it is best to always > use the accessor methods when they exist. i hanker to bet many of us do > not do this. and i think this has to do with the fact that the > @variables are more convenient, due to the extra thoguht that must go > into determining when self must be used (albiet small), and the fact > that @ is shorter than self. other reasons? I have to admit that neither of those things bothers me at all. Ruby is concise enough that three characters one way or another, on relatively rare occasions, doesn't bother me. And, as I've said, knowing when to specify the receiver should not be a burden; it just means you know what your code is doing. (We've probably spent more thought and typing on this thread than everyone on this list will spend thinking about and typing 'self.' in their combined lifetimes :-) In any case -- assigning to @var is only convenient if it does what you want. I tend to lean toward using the accessor methods for attributes, even inside a class, since those methods may be doing things far beyond just setting or getting the instance variable associated with their name. The raw @thing=x probably works, in practice, quite often, but if the object has a #thing= method, there might be a real necessity to channel assignments through that. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav