From: Trans Date: 2007-10-16T00:23:43+09:00 Subject: Re: RubyTraits 0.1 On Oct 15, 8:11 am, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: RubyTraits 0.1" > on Mon, 15 Oct 2007 23:39:24 +0900, Trans writes: > > |> Even though I like the concept of traits, traits and modules are too > |> close in concept, too different in behavior. Having both in a > |> language may cause confusion. Too bad I didn't know about traits when > |> I designed Ruby. > | > |What behavior difference are you thinking about? To the end-programmer > |wouldn't it look mostly the same? > > Yes, that's why I said "too close" to have them both. > > The biggest difference I concern is traits inject attributes where > modules create relationship. Modules can conflict (overriding rule > applied), traits can't. > > If I knew traits before designing Ruby, I'd have chosen traits over > modules. But that's the life. I see. So you don't really like the fact that modules fit into the inheritance chain? That's interesting. The traits lib I wrote for Facets actually uses the inheritance. Eg: class Module def +( other ) mod1 = other.clone mod2 = clone mod1.module_eval{ include mod2 } return mod1 end So instead of injection there's relationship, but in every other respect its like traits. Is that not a good Ruby-esque way to do traits? Maybe even better than injection actually? T.