2015-01-28 16:41 GMT+01:00 Laura Risani <laura.ris...@gmail.com>: > Hi all, > > What is the explanation why Smalltalk designers preferred single > inheritance+traits to multiple inheritance? Why is the former better than > the latter? > Do traits let you share state also or only behavior? >
Traits only share behaviors. As you guessed, it is still questionable to many people if multiple inheritance is good because state can be inherited multiple times. For example, what do happen if C inherits from A and B and that both A and B have a field name i. There are existing solutions for this problem but they're all not perfect. Traits were implemented language-side only. If you want you can implement multiple inheritance language side only too (as for traits, you'll have to add virtual copies of methods and if state is shared too you'll have virtual copies of instance variables to run on our current VM), and see which one you prefer. I'd be glad to hear your feedback on that. > Best, > Laura >