From: Christoph Date: 2005-05-16T08:37:03+09:00 Subject: Re: Bug printing classes - Re: infinite number of singleton_classes David A. Black schrieb: > > I'd rather just see the #inspect bug fixed :-) > > I don't think having (class << Class; self; end) be the superclass of > these singletons is a problem. At least, if one had a reason to want > to go higher than one level (for example, adding a class method to a > singleton class -- has anyone done that?), it wouldn't really matter > what the class's superclass was. If you are "singleton class" you only have to do house keeping for a one instance only. There is a potential benefit of inheriting house keeping methods but this is broken if Klass is the superclass of all "higher order" singleton classes. If inheritance does not work any more "higher order" singleton classes are pretty much fake "higher order" singleton classes. --- # From Ara example class C class << self class << self def class_method_generator name module_eval <<-code def #{ name }; @#{ name }; end alias #{ name }? #{ name } def #{ name }= value; @#{ name } = value; end code end end %w( a b c ).each{|meth| class_method_generator meth} end end class B < C end C.a = 42 p C.a B.a = 'forty-two' p B.a class << B class << self class_method_generator :wont_work_in_182 end end ---- /Christoph