From: Thomas Sawyer Date: 2009-02-02T11:51:44+09:00 Subject: Re: Object#singleton_class in Ruby 1.9? Sean O'halpin wrote: > On Sat, Jan 31, 2009 at 8:03 PM, Thomas Sawyer > wrote: > [snip] >> >> end >> > > I like this - how do you see it working alongside the proposed > #class_extension from a while ago? > > I guess #extend would work as above (i.e. defines singleton methods on > instances), where #class_extension (or #class_extend?) methods/modules > would both extend a class and be inherited by subclasses. I forget > where the discussions on module inheritance ended up. Would you have a > #module_extend method too or would #class_extension work for both > classes and modules (in which case it should be renamed or alased)? Hey, that's a really good point. #class_extension is very much the same thing, but specifically designed to allow classes to carry the modules behavior through the class-level hierarchy. So accordingly a better name would be #class_extend. But as with the original, I still think that this doesn't convey enough of what it actually does to the inheritance chain, and likewise why #module_extend doesn't really make sense. But a concise name for #extend_and _propogate_through_the_class_hierarchy seems elusive. > I think you're onto something here - conceptually, #extend, singleton > methods and the-class-that-cannot-be-named are closely related but you > wouldn't know that from their names (or lack of them). > > Perhaps #extension_class? My goodness, when you put it like that it does seem rather obvious. I wonder why no one has ever thought of that before. T. -- Posted via http://www.ruby-forum.com/.