Can we just have struct inheritence already?
XavierAP
n3minis-git at yahoo.es
Fri Jun 14 14:47:15 UTC 2019
On Thursday, 13 June 2019 at 22:13:51 UTC, Manu wrote:
>
> So don't implicitly convert to the base type?
> B extends A, but I don't think it's a kind of A as for
> polymorphic classes.
What is the benefit of
struct A { void fun(); };
struct B :A {};
B b;
b.fun;
compared to
struct A {};
struct B { A a; };
B b;
b.a.fun;
Less typing is good but stuff happening magically/unexpectedly
for a neutral reader of the code (e.g. implicit casts) is not.
And if on the other hand, !is(B:A), then what is the advantage,
and the use case?
Your OP pattern may have good alternatives that don't repeat code
either, but produce more explicitly readable code?
More information about the Digitalmars-d
mailing list