From: Trans Date: 2007-10-17T04:43:58+09:00 Subject: Re: RubyTraits 0.1 On Oct 15, 8:38 am, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: RubyTraits 0.1" > on Tue, 16 Oct 2007 00:23:43 +0900, Trans writes: > > |I see. So you don't really like the fact that modules fit into the > |inheritance chain? That's interesting. > > Actually they both have their own good. I like them both. I dislike > to have them both in a language. Traits injection is clear and less > error prone (there's no possibility of conflicts), but sometimes > method overriding is _very_ useful, where aliasing is very poor way to > create method combination. > > If someone come to the idea to allow modules to have merits from both > mixins and traits at once (without demerit), I'd love to hear. I couldn't help but think about what a solution to that might look like --it would have to have the layerability of modules but the simplicity of traits. To do that, I think methods would have to be more independent. Instead of a Method being a single function belonging to class (or module/trait) it would be a linked-list of them. Each of these would have a second link tying it to the trait/ module. Eg. .-> Class1 | .-> TraitX .-> TraitY .-------- | | | -> foo_method-> foo_method -> foo_method '-------- It would also be possible to do around advice very easily too, because a method could be added to the chain that's not tied to a Triat/ Module. .-> Class1 | .-> TraitX .-> TraitY .-------- | | | -> foo_method -> foo_method -> foo_method -> foo_method '-------- #super would be dynamically resolved by following the link. I think this could provide the advantages of both traits and modules in a single system. T.