From: "David A. Black" Date: 2005-05-16T10:54:34+09:00 Subject: Re: infinite number of singleton_classes On Mon, 16 May 2005, Lionel Thiry wrote: > You have skipped this part of my post in your answer: > ----8<---- > And, please note this: I agree with you. There is nothing wrong or harmfull in > the current behavior, while looking from the point of view of a ruby user. But I > think it may be different from the point of view of a language designer and I > like to take count of it. > ----8<---- I didn't have anything to add to it, so I didn't quote it back. Otherwise we get into infinite recursion :-) > The feature is currently avaible, but unless Matz state otherwise, it is an > accident, it shouldn't have never happened. Why? Because it may disapear in any > future version of ruby. Who said it? Matz himself. It then should be accessible > only via special module like evil.rb if one really want the feature. If it disappears, it can't be accessible from any module, at least not in exactly that form. > On the other hand, if it was said that ruby won't never change about singleton > methods hold in singleton classes, I wouldn't care at all about this. There's a bit of a paradox there. If Ruby shouldn't contain anything that might be absent in a future Ruby, then Ruby today must be exactly what Ruby in the future will be.... If singleton classes disappear, lots of things will change, possibly including: class << obj # this form of the class keyword X = 1 # constants -- where would this go? def self.x # class methods on the singleton class end end as well as just the fact that you can call Class's instance methods, in general, on singleton classes. So if you apply the rule: it should never have happened because it may disappear in a future version of Ruby, then all of this should never have happened and should disappear. But so should lots of other things, because Matz is planning lots of changes. So that means Ruby should be turned into future Ruby *now*. But that takes time :-) David -- David A. Black dblack@wobblini.net