From: Robert Dober Date: 2007-04-23T00:05:58+09:00 Subject: Re: Object#method and super. Is this a bug? On 4/22/07, Philipp Taprogge wrote: > Hi! > > Thus spake Robert Dober on 04/22/2007 11:17 AM: > > Sorry but this is not true, we get a method object bound to the > > instance which can be called without any problem. Look at this code, > > just to convince you > > You are right in that the method object is bound to _an_ instance. > The question is: instance of what? > > Your code differs from the OPs example in that your method is > defined inside the same class. If you grab this with method(), you > of course get a method object in the context of the instance that > defined it. Reflection would be no good if this was not the case. Ok we agree on this, I did not read this in your mail, sorry. > > If, however, the method is defined in another module and included, > the call to this method and all methods it calls itself are > dispatched at runtime. Well but not more or less than if the method is defined in the class directly, dispatching on runtime is another obvious need of the dynamic nature of ruby. I honestly fail to see the difference. > > In the OPs example, method() gets you the boo() method out of the > module Maybe I am starting to read you here the difference is that the included method is a method of the proxy class/module of the mixin, it is not a method of the module though, while the method you get when it is directly defined in the class is a method of the class as one can see here irb(main):055:0* module M irb(main):056:1> def a; end irb(main):057:1> end => nil irb(main):058:0> class I irb(main):059:1> include M irb(main):060:1> end => I irb(main):061:0> class S irb(main):062:1> def a; end irb(main):063:1> end => nil irb(main):064:0> I.new.method(:a).inspect => "#" *************************** irb(main):065:0> S.new.method(:a).inspect => "#" ************************** > instance including the module. > > > The behavior seems wrong to me too > > Heh... this, of course, is a totally different question... > I might agree with you that a consistent behavior between native > method calls and reflected method calls would be better, but that > does not mean that the current behavior is a bug. As far as I > understand it, it's intended. I do not claim to understand the full implications to hide super in this case, but I would like to know more about it. With my limited knowledge I feel the Proxy should behave completely transparently. And even if it is intended, it might still be worth changing. Thx for the discussion so far. > > Regards, > > Phil > > Robert -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw