From: George Ogata Date: 2007-02-19T02:26:23+09:00 Subject: Re: More flexible inheritance On 2/19/07, Pit Capitain wrote: > George, I'm not Tom, but I think that for redefining a method, instead of > > class X > def a; "a2"; end > end > > internally you would do something like > > X.ancestors[ 1 ].module_eval { > def a; "a2"; end > } > > Everything you would do with class X in normal Ruby you would do to the > anonymous module being the first in the ancestors chain. Hi Pit, Ah ok, I was overlooking the fact that *original* methods of X would live in an anonymous module as well. It's an interesting idea. It does still change the existing semantics a little, though. Currently, if you do: class C def f; 'C'; end end module M def f; 'M'; end end C.send(:include, M) ...C still comes first in the lookup path. You'd need to ensure that the anonymous modules (eigenmodules? ;-) come at the front of the ancestor chain if you wanted to preserve this behavior. But yeah, interesting idea! Regards, George.