From: Christoph Date: 2005-05-17T00:12:44+09:00 Subject: Re: infinite number of singleton_classes 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 --- 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. /Christoh