From: Robert Klemme Date: 2005-05-02T04:44:27+09:00 Subject: Re: arg, metaclass bug found? "ts" schrieb im Newsbeitrag news:200505011024.j41AOgMw007111@moulon.inra.fr... >>>>>> "R" == Robert Klemme writes: > > R> Well, yes, that's what I concluded. But why is that so? What's the > R> reasoning behind this? After all, both singleton classes are just > there for > R> a single object although that happens to be a class instance. This > change > R> might even break some code, I'm not sure. > > Well, I've tried one day to give a *STUPID* example > > Imagine that you have > > > class Class > def new(*args, &block) > obj = allocate > obj.send(:initialize, *args, &block) > obj > end > end > > class Array > def self.allocate > # do some magic here to create the type array > end > end > > Now if you write > > class A < Array > end > > A.new > > You want with `A.new' re-use the method ::allocate which is defined in the > singleton class (Array). This mean that (A) must inherit from (Array) Sounds reasonable. Thanks for that example! Still, this seems quite some change to me, doesn't it? I guess this inheritance does only work for class instance singleton classes - at least that seems the most reasonable (only?) way to do it to me. That would also reduce the likelyhood of code breakage. .... It seems, incombatibility isn't that big issue as I thought initially. That's nice! Kind regards robert