Christoph a ñÄrit : > Ara.T.Howard / noaa.gov schrieb: > 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 > --- > you would expect the following method lookup path for a > singleton class of "height" 5 > --- > class A; end > class B < A; end > b = B.new > > b.m(5) <- B.m(4) < A.m(4) < Object.m(4) < > Class.m(3) < Module.m(3) < Object.m(3) < > Class.m(2) < Module.m(2) < Object.m(2) < > Class.m < Module.m < Object.m < > Class < Module < Object < Kernel > --- > > From a practical point of view this would be rather silly, so Matz bend > the rules, and "benevolently ruled" the following to be true > --- > b.m(5) < Class.m < Module.m < Object.m < > Class < Module < Object < Kernel > --- > > I personally still prefer honest exception raising over a trickery like > this. What an impressive demonstration. Let me add more precision to your affirmation: b.m(5) < B.m(4) # => nil B.m(4) < A.m(4) # => nil A.m(4) < Object.m(4) # => nil Object.m(4) < Class.m(3) # => nil Class.m(3) < Module.m(3) # => nil Module.m(3) < Object.m(3) # => nil Object.m(3) < Class.m(2) # => nil Class.m(2) < Module.m(2) # => nil Module.m(2) < Object.m(2) # => nil Object.m(2) < Class.m # => true Class.m < Module.m # => true Module.m < Object.m # => true Object.m < Class # => true Class < Module # => true Module < Object # => true Object < Kernel # => true Then, we have to choose between two things: limit the "height" of singleton class, or correct that inheritence model. I'd be for the first one. -- Lionel Thiry Personal website: http://users.skynet.be/lthiry/