From: Paul Brannan Date: 2003-12-04T02:36:21+09:00 Subject: Re: mixin vs. multiple inheritence On Wed, Dec 03, 2003 at 11:51:22PM +0900, Dave Thomas wrote: > module A; end > module B; include A; end > module C; include A; end > class D; include B; include C; end > > You can build as complicated a mixin graph as you can a MI graph. The > difference is that because mixins are modules, they don't have their > own state, but instead parasitically use the state of the class into > which they are mixed. This eliminates the underlying issue with MI, > where there may be two _instances_ (logically) of the class at the top > of the diamond. Mixins in Ruby always create a linear graph. Consider your example with a method foo added to each class that prints the name of the class and then calls foo in the base class: module A; def foo; puts "A"; end; end module B; include A; def foo; puts "B"; super; end; end module C; include A; def foo; puts "C"; super; end; end class D; include B; include C; def foo; puts "D"; super; end; end D.new.foo The resulting output is: D C B A I know of no way to get C#foo to call A#foo here. Paul