From: "David A. Black" Date: 2005-07-13T02:26:21+09:00 Subject: Re: adding attributes (attr_*-style) to single objects On Wed, 13 Jul 2005, Joel VanderWerf wrote: > Joel VanderWerf wrote: >> David A. Black wrote: >> ... >> >>> class C >>> add_attr_accessor(:x) >> >> attr_accessor(:x) >> >>> end >> >> >> The method names are too close. I would have guessed these did the same >> thing. >> >> I like the idea, but why not just make #attr_accessor public, so you can >> write: >> >> self.attr_accessor :x >> >> and make it clear that you are not adding an instance method. > > > Duh. That suggestion made no sense. > > Maybe something like > > my_attr_accessor :x > > to add an accessor to the current self, rather than to instances of the > current self. I don't think the "my" scales well to non-class objects though: str = "a string" str.my_attr_accessor :x It's not clear here what "my" is (or, to put it another way, what "not my" would be). I can see that attr_accessor and add_attr_accessor are close. However, I'd be glad to enter a new era where people had to be careful about that one name, if in return we could get some relief from the confusion that seems to proliferate around this whole thing, spilling over into singleton classes and class variables. David -- David A. Black dblack@wobblini.net