From: dblack@... Date: 2006-06-09T19:58:19+09:00 Subject: Re: Why the lack of mixing-in support for Class methods? Hi -- On Fri, 9 Jun 2006, Logan Capaldo wrote: > > On Jun 8, 2006, at 10:25 PM, Yukihiro Matsumoto wrote: > >> Hi, >> >> In message "Re: Why the lack of mixing-in support for Class methods?" >> on Fri, 9 Jun 2006 09:22:55 +0900, transfire@gmail.com writes: >> >> |Considering the above (which by the way should also have an 'include >> |Beanable'), a notation that has some similarity and is available for >> |use: >> | >> | class Beanbag >> | self << Beanable >> | end >> >> I like this more than others, but I worry about that this is less >> descriptive than other at the same time. For example, how one can >> know whether "include" does not injects module methods, where "<<" >> does. >> >> matz. >> > > well we have class << self, which involves singleton methods > > why not > class Beanbag > include << Beanable > end > > which would also involve singleton methods? I'm not sure << really evokes "connected in some way with singleton methods", though. Then again, I'm not sure what's wrong with "extend", so I'm probably a bit out of the loop on this discussion. > (Of course then include has to be a keyword (or "include <<" at > least)) Not necessarily: class MyModule def initialize @list = [] end def include(*args) if args.size.zero? @list else @list.concat(args) end end end m = MyModule.new m.instance_eval { include "a", "b" include << "c" p @list # ["a", "b", "c"] } David -- David A. Black (dblack@wobblini.net) * Ruby Power and Light, LLC (http://www.rubypowerandlight.com) > Ruby and Rails consultancy and training * Author of "Ruby for Rails" from Manning Publications! > http://www.manning.com/black