Struct inheritance

Richard Andrew Cattermole (Rikki) richard at cattermole.co.nz
Thu Sep 19 15:56:06 UTC 2024


As an idea this has come up in Razvan's DConf 2024 talk.

1. Support inheritance on struct, for other structs.

```d
struct Parent {
     ...
}

struct Child : Parent {
     ...
}
```

2. ``opDispatch`` function, may work in place of ``alias this`` 
when no parent exists.

```d
struct Parent {
     T thing;
     ref T opDispatch(string:"")() {
         return this.thing;
     }
}

struct Child : Parent {
}

Child child;
T got = child;
```


More information about the dip.ideas mailing list