Ara.T.Howard / noaa.gov a ñÄrit : > On Tue, 17 May 2005, Christoph wrote: > >> Ara.T.Howard / noaa.gov schrieb: >> >>>> misunderstood something once again? >>> >>> >>> >>> well - sorta ;-) >>> >>> i only meant to say that the behaviour is consistent and, although >>> there is no >>> regular ruby idiom that makes use of it now, there may well be in the >>> future. >> >> >> Actually the behavior is not consistent - assuming the definition >> ---- >> public # create meta objects >> def m(height =1) >> height.zero? ? self : class << self; self end.m(height -1) >> end >> ---- >> >> and the natural inheritance assumption, that the class relation >> >> X < Y # true, implies >> X.m < Y.m # true > > > here we depart. i don't assume this because X's singleton class is just > that > : a singleton (eg. one) class with no relation to that of Y's. > > [snip] > > so the only reason that > > class C; end > class B < C; end > > class << C > def foo; 42; end > end > class << B > def bar; 'forty-two'; end > end > > permits > > B.foo > > is __not__ because B.singleton_class < C.singleton_class. rather it is > because the search path for a method is, naturally, up the ancestor list > hierarchy and, at each step along the way, each class additionally looks > 'sideways' into it's singleton_class (it's pocket) but not into the > singleton_class of any other classes since, by definition, those classes > belong only to the object that created them - it would be like looking into > someone else's pockets ;-) > http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/140562 If you really want ruby2 works the way you described it, I advice you to urgently post an RCR for it. -- Lionel Thiry Personal website: http://users.skynet.be/lthiry/