From: Chris Pine Date: 2003-01-04T01:48:20+09:00 Subject: Re: How to call overridden methods (finally!) ----- Original Message ----- This is a stupid example, but with your modified version of ruby try a = Numeric.instance_method(:to_int) b = Method.instance_method(:call).bind(a) b.call ---------------------------- I didn't actually modify my version... never hacked the interpreter before. That was Paul Brannan's code, I think. But, as your example certainly shouldn't work (and really *can't* work, since it makes no sense... #to_int isn't bound to anything!), one of two things could happen: the interpreter raises an exception, or it crashes. I'm assuming that it crashes in this case, because otherwise I don't see any problem at all. (It already raises an exception! Telling me that `to_int' is unbound is a more helpful exception, anyway.) Still, this code doesn't crash the interpreter: a = Numeric.instance_method(:to_int) class UnboundMethod def call super end end a.call So if your example crashes, I see your point... sometimes it is inappropriate to call a method from a parent class on a child classes instance... but only very rarely! And when it is *impossible*, as in this case, I have to ask: Should UnboundMethod really be a child of Method?? If anything, it seems like it should be the other way around (though the English (and Japanese?) of it might falsely suggest otherwise). And how is this related to classes only, and not to modules? I could design a module with similar problems, but when it crashed we would call it a bug. :) In any case, it seems to me that there would be relatively few places where this would be a problem, and that they are easily fixable. Is this a design decision, or a fear of implementation? It wouldn't be too hard to make a bunch of objects of the base and library classes and have them exhaustively call all of thier ancestors' methods. I guess my ultimate question is this: Does this feature exist because it is bad design to allow people to call parent methods from child instances (in which case how do we justify `super'?), or it is a good idea (like super), but it isn't implemented because it might cause crashes? Chris