From: Mathieu Bouchard Date: 2001-10-06T07:59:40+09:00 Subject: [ruby-talk:22146] Re: Ruby and multiple inheritance On Sat, 6 Oct 2001, Paul Brannan wrote: > On Sat, 6 Oct 2001, Alan Stern wrote: > This isn't quite the same as multiple inheritance. For starters, every > time you include a new module, you are creating an anonymous proxy class > that the current class inherits from. An implementation detail irrelevant to the understanding of Ruby's inheritance. > This is different from MI, because > while MI can create "the diamond pattern" and tree shapes and other crazy > things, using a mixin is very linear. you can create the diamond pattern and tree-inheritance with Ruby's model. there are some different details, and so some things are not possible with Ruby's model, but some things that are possible with Ruby's model which are not possible with "classic" multiple inheritance. > With real MI, you would have two separate methods in two separate > classes, each callable from the derived class (though you may have to > clarify which one in order for you compiler/iterpreter to know). Not > being able to specify which method to call seems limiting. Say there's a diamond relationship with B there's no well-defined way to initialize instance data in a mixin (with > inerhitance in Ruby, you initialize the base class with super()). there _is_ a well-defined way to initialize mixin data, as you can deduce from the message you replied to, and from what I've said above. > I've found that not thinking of mixins as a replacement for MI has been > beneficial to my health. MI is not a replacement for Ruby's model. ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju