ion icon indicating copy to clipboard operation
ion copied to clipboard

Design of Multiple inheritance of data classes

Open krisnye opened this issue 3 years ago • 0 comments

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.

krisnye avatar May 07 '22 23:05 krisnye