I was a little surprised the subclassing syntax didn't do structural concatenation for struct's. That is,

```d
import std.stdio : writeln;

struct A {
 int a;
 void printA() {
  println(this.a);
 }
}
struct B : A {
 int b;
 void printAB() {
  this.printA();
  println(this.b);
 }
}

void an_A_fun(A arg) {
 arg.printA();
}

void main() {
 B foo;
 foo.a = 1;
 foo.b = 2;
 foo.printAB();
 an_A_fun(foo);
}
```

Unlike classes, this would guarantee storage adjacency, and still preserve its behavior as a value rather than an object reference. And then you get to share code for common initial parts of a given struct.

Reply via email to