From: Robert Klemme Date: 2007-01-21T03:15:07+09:00 Subject: Re: Minor Change Proposal for Classes 'Object' and 'Method' On 20.01.2007 18:54, Phrogz wrote: > Robert Klemme wrote: >> On 19.01.2007 19:33, 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. >> I opt for "defining_class", because this precisely states what it >> returns. Some might find it a bit much of typing but I think we have >> much worse cases in Ruby (attr_accessor for example, which is much more >> often used). If someone can come up with an equally clear name which is >> shorter, that's fine with me. > > I have two objections to this: > 1) The fact that there are some methods which are a pain to type does > not mean that we should feel OK about making all methods a pain to > type. Certainly, verbose naming matters less of the method would be > infrequently used (as this one would). But we should continually strive > for a balance between clarity and terseness (and I see that you > implicitly agree with that, given your last sentence). Exactly. > 2) If a method is rebound to a new object, what is desired (I think) is > the current 'parent' class of the method, not the one where it was > defined. If derivatives of the word 'defined' are in the method name, > this (edge) case will be confusing. I am not sure I understand what you mean by "parent class". If you refer to the class of the instance the method is bound to then that would be available via meth.receiver.class. When rebinding a method to another receiver then the defining class does not change, does it? Did I miss something? > If we're going verbose, I prefer #owning_class. Striving for terseness, > however, I prefer #owner. To me, that's pretty clear. In my ears "owner" sounds more like the instance ("receiver"). "owning_class" seems clearer although I still prefer "defining_class" as it seems a bit clearer to me. YMMV though... Kind regards robert