From: Alder Green Date: 2006-06-09T00:49:19+09:00 Subject: Re: Why the lack of mixing-in support for Class methods? On 6/8/06, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Why the lack of mixing-in support for Class methods?" > on Thu, 8 Jun 2006 17:02:35 +0900, "Alder Green" writes: > > |Still, it's unclear to me why this very natural functionality isn't > |built into the default append_features. > > Mix-in is used for several purposes and some of them can be hindered > by inheriting class methods, for example, I don't want to spill > internal methods when including the Math module. I am not against for > some kind of inclusion that inherits class methods as well, but it > should be separated from the current #include behavior. > > matz. Hi Matz :) I see your and Dblack's point about the need for an #include that won't inherit the class methods. And I agree that it's probably a good idea to keep #include behaving as it does right now. So adding a separate #inherit seems like a very good idea. I encountered the need for #inherit when I wrote Foo as a class, and then later discovered I needed to have Foo features in class Bar that already has parent Baz. It seems Ruby would be much more flexible if I could simply: module Fooable # instead of class Foo ... end class Foo inherit Fooable end class Bar < Baz inherit Fooable end This is not a rare need, at least not for me. I'm pretty new to Ruby, and alredy needed to do this 5 times. Also I'd argue current lack of support of this encourages programmers to encapuslate functionality in classes even when they don't need to instantiate it, and a module would be more appropriate. Since you don't seem averse to the idea, and there are others (below, in this thread, and earlier in other threads) who share the same need, what do we need to do to have #inherit added as feature? -- -Alder