Can we just have struct inheritence already?
Andre Pany
andre at s-e-a-p.de
Sun Jun 9 08:31:40 UTC 2019
On Sunday, 9 June 2019 at 08:05:34 UTC, Manu wrote:
> I am really really tired of this pattern:
>
> struct DerivedStruct
> {
> static if (BaseStruct.tupleof.length > 0)
> BaseStruct base;
> else
> ref inout(BaseStruct) base() inout { return
> *cast(inout(BaseStruct)*)&this; }
> alias base this;
>
> // derived members
> //...
> }
>
> Imagine if we could just write:
>
> struct DerivedStruct : BaseStruct
> {
> // derived members
> //...
> }
>
> Just imagine!
Users would then also expect they can use the derived structures
in places where there ancestors are expected, similar like with
classes;)
And also they can overload the functions of this structures.
Then we need to add a monitor field to all structures to enabled
it.
It seems like a small change, but opens a huge area of problems.
Kind regards
Andre
More information about the Digitalmars-d
mailing list