3 ms·
Ruby 2.0 was (and hopefully still) earmarked to have traits which are an enhancement on mixins providing a much better & refined compositional implementation.
by draegtun 14y ago
Ruby 2.0 was (and hopefully still) earmarked to have traits which are an enhancement on mixins providing a much better & refined compositional implementation.
Thus it (should) allow you to do things like excluding or renaming methods/traits ala Perl roles - https://metacpan.org/module/Moose::Manual::Roles#METHOD-EXCLUSION-AND-ALIASING https://metacpan.org/module/Moose::Manual::Roles#METHOD-EXCL...
- pabloh 14y agoRefinements will be at the 2.0 release but I wouldn't call that feature "multiple inheritance".
- draegtun 14y agoNeither would I because refinements are something completely different to traits! Refinements proposed in Ruby 2.0 allows you to localise monkey-patching much like you can do in Perl with dynamic scoping (for e.g.: http://news.ycombinator.com/item?id=1603321 http://news.ycombinator.com/item?id=1603321 | http://news.ycombinator.com/item?id=3455507 http://news.ycombinator.com/item?id=3455507). For further info on Ruby refinements see here: http://timelessrepo.com/refinements-in-ruby http://timelessrepo.com/refinements-in-ruby Traits are an improvement to mixins. IIRC Matz gave a talk (RubyConf 2010?) where he describes the proposed traits implementation. Here's one set of slides (not Matz's talk) which also shows some traits examples - http://www.slideshare.net/fabiokung/ruby-20-to-infinity-and-beyond http://www.slideshare.net/fabiokung/ruby-20-to-infinity-and-...