Can we just have struct inheritence already?
XavierAP
n3minis-git at yahoo.es
Fri Jun 14 16:01:48 UTC 2019
On Friday, 14 June 2019 at 14:47:15 UTC, XavierAP wrote:
> 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.
>
> 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?
Moreover, even if your inheritance did not produce (static)
polymorphism in the hard sense i.e. !is(B:A), it would in the
duck-typed sense, in templates! So inheritance without
polymorphism is inconsistent.
struct A { void fun(); };
struct B :A {};
void gun(A x) { x.fun; }
void hun(T)(T x) { x.fun; }
B b;
b.gun; // error?
b.hun; // ok
More information about the Digitalmars-d
mailing list