From: Joel VanderWerf Date: 2004-11-13T05:41:35+09:00 Subject: Re: possible bug in method dictionary Ryan Davis wrote: > > On Nov 12, 2004, at 3:23 AM, nobu.nokada@softhome.net wrote: > >> It silently redefines and discards old one. > > > OK. I think I have a more clarified issue now. Thank you very much Nobu > for forcing me to look at this w/o inline. The key difference between > what your version does and what inline does is in classes vs modules. > Inline defines modules and then mixes them in with include. Maybe Inline > shouldn't do that anymore, I dunno. It turns out that C extensions > aren't even necessary to show what I am talking about. For example: > > class MyTest > def test_method > puts "running stupid version" > end > end > > module MakeBetter > def test_method > puts "running better version" > end > end > > t = MyTest.new > t.test_method > > class MyTest > include MakeBetter > end > > t.test_method > > # just in case it is some static thing per instance: > t = MyTest.new > t.test_method > > ---- > > Again... I'm not sure if this is a bug. It really depends on the > language definition. > Isn't this behavior an expected consequence of the method search order trhough the ancestors of the class? p MyTest.ancestors # ==> [MyTest, MakeBetter, Object, Kernel] MyTest comes before MakeBetter, because MakeBetter is a module included in MyTest.