From: "Mauricio Fernández" Date: 2003-01-10T07:57:44+09:00 Subject: Re: attr_reader/writer vs. attr_accessor w/ access control On Fri, Jan 10, 2003 at 07:14:24AM +0900, dblack@candle.superlink.net wrote: > > except for the fact that instance variables can spring into existence > > dynamically, i wonder why they aren't simply attr_accessor by default and > > access control the sole means by which we make them visible or invisible to > > the outside. > > This would mean, for one thing, that every object would respond to > every message; there would no longer be a distinction between those > messages an object understood and those it didn't. If you said: > > s = "abc" > s.keys > > then you'd get the value of the @keys instance variable of s, instead > of an indication that s doesn't respond to #keys. And so forth.... > Rather more i.v.'s in the landscape than one wants :-) That would not happen if accessors were, say, protected by default. But then you'd have to 'publicize' them anyway, and the situation wouldn't be that different from the current one. OTOH if instance variables were private (not accessible by subclasses) all this would be much more relevant. I really felt that this was The Right Thing but matz doesn't [55201]. I think the main point was that inheritance is anyway a very strong relationship, so this apparent breach in data hiding is not that important. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com *** PUBLIC flooding detected from erikyyy THAT's an erik, pholx.... ;) -- Seen on #LinuxGER