From: Trans Date: 2007-10-24T20:05:28+09:00 Subject: Re: Ruby-Traits 0.2 released (sorry long) On Oct 23, 4:16 pm, "Robert Dober" wrote: > Hi list > > after some very interesting input I decided to rewrite Ruby-Traits completely. > > http://rubyforge.org/frs/?group_id=4642&release_id=15737 > > I have decided to implement two different kinds of traits: > * ruby-traits > and > * pure-traits. > > In detail: > * ruby-traits are mimicking some of the properties of traits but violate the > flattening property. They implement some of the more dynamic features > of modules and are in fact module based. The code is heavily influenced > by Thomas Sawyer's traits from Facets. Many thanks to Thomas for the > permission to use his code. Note that Thomas' traits of Facets is yet another > different beast. > > * pure-traits implement traits in the strict sense of their definition > here:http://portal.acm.org/ft_gateway.cfm?id=1028771&type=pdf&coll=GUIDE&d... > > They obey the flattening property, using a trait is exactly as defining > its methods inline, no modules are used and inheritance is unchanged. > All trait combination rules are obeyed (associative, communative, e.g.) > > The main purpose of pure-traits is to play around with them and to see the > benefits and shortcomings of traits based design. > > The syntax has changed, again inspired by Factes, trait aliasing is done > via #* now, thus traits aliased and combined can be expressed more > naturally: > t1 * { :t1_a => :a } + t2 * { :t2_a => :a } > works now as expected. > > In addition to the traditional trait operations +, - and *, I have > implemented & to allow of selective usage of methods. > I believe that the usage of this is normally a bad sign for the design > but sometimes it might be a handy feature. [snip] Whew! Yep, long, but interesting. I'll have to check the ruby-traits code and see if there's any cross-pollination to be had. Seems like maybe the main difference between this and Facets is the use of the Traits < Module class (where as Facets just extends Module). I'm also curious about the & method. Great work! T.