ion
ion copied to clipboard
Design of Multiple inheritance of data classes
Intention is that diamond inheritance brings in at most one copy of classes fields.
class Body
mass: >= 0
class Animal extends Body
class Robot extends Body
class Cyborg extends Animal, Robot
An instance of Cyborg would only have a single mass field.
At runtime, I'm thinking that there is a vtable where you lookup an array of field offsets for each Class where the array length == length of all that classes (and inherited) fields.
Fields should be ordered such that for many classes (all without multiple inheritance) and many fields static offsets are usable and vtables aren't needed.