Support multiple inheritance in ABI files
I found out today that support for multiple inheritance does not exist in the ABI files for smart contracts at this time. In discussion with Todd Fleming, a workaround was suggested.
Todd Fleming, [09.01.19 14:13] class A {...}; class B { A bar; };
Todd Fleming, [09.01.19 14:15] It takes updating 3 abi serializers, eosio-cpp’s generator, plus it affects community-written abi serializers.
Todd Fleming, [09.01.19 14:16] We have to see a very large advantage before we update the abi format because of the amount of coordination it takes
Support for all standard C++ features will help support mass adoption and bring more developers to the platform. So I want to open this issue to allow those who want multiple inheritance to express their support
My use case would be to write a generic order matching algorithm for Chintai that can thoroughly utilize polymorphism and be maintainable.
It may take a hard-fork to support the new API format with multi-inherentance. However at the moment there is a workaround: class A {...}; class B {...}; class C: public A { B b; ... }; The abi file is generated automatically by cdt so you just need to re-compile it again.
The need for multiple inheritance can disappear when you separate these concerns:
- Contract logic
- Data storage
See, for example, CppCon videos on data-oriented design.
The issue with multiple inheritance is data layout and what that means for virtual bases and concrete bases. This same kind of pattern that you are looking for can still be utilized, but the polymorphism should be hoisted from the type and into the functionality (this is what tbfleming was referring to), please see https://www.youtube.com/watch?v=QGcVXgEVMJg (this is a video of one way to do this).
This issue has been open for three weeks now and no one else has expressed any desire for supporting multiple inheritance. I'm giving it another week and will close it if there's no further comments.