From: gwtmp01@... Date: 2007-01-20T05:37:38+09:00 Subject: Re: Minor Change Proposal for Classes 'Object' and 'Method' On Jan 19, 2007, at 1:33 PM, Yukihiro Matsumoto wrote: > Wolfgang's proposal can be divided into three methods. > > #receiver that returns the bound object of the method object. > #name that returns the name of the method object. > and a method that returns the class which holds the method. > > Does anybody have good name candidate for the last one? I have > already implemented the first two methods in the local copy of the > repository. Method#receiver Method#name Method#origin # module/class with definition of method Kernel#origin(name) # module/class where named method is found # via standard method lookup process on the # receiver. # nil if no matching method found Kernel#origin!(name) # same as origin but reports location of # any matching method_missing implementation # nil if no method_missing applies Not sure about origin vs. origin! names but it seems reasonable to be interested in whether method_missing is triggered or not. I've often thought it might be nice to have a 'magic' reference similar to 'self' that referenced a method object matching the current receiver and method: def factorial(n) return 1 if n.zero? myself[n-1] * n end So in that example, 'myself' would be an instance of Method bound to the top-level object and the method Object#factorial. Combined with the other proposed methods you get: myself.name # => 'factorial' myself.receiver # => main myself.origin # => Object Not sure about the 'myself' name, but I like the idea. Gary Wright