digitalmars.D.learn - dlang custom keyword for struct/class
- Vitaliy Fadeev (29/29) Sep 17 2023 Is it possible to write like this in D?
- FeepingCreature (4/33) Sep 17 2023 No, there's no struct inheritance. But you can just write the
Is it possible to write like this in D? ```d struct Message { ulong timestamp; } Message LongMessage { ubyte[255] s; } // // it mean // // struct LongMessage // { // Message _super; // alias _super this; // ubyte[255] s; // } // // or // // struct LongMessage // { // ulong timestamp; // ubyte[255] s; // } ``` Is it possible?
Sep 17 2023
On Sunday, 17 September 2023 at 15:55:37 UTC, Vitaliy Fadeev wrote:Is it possible to write like this in D? ```d struct Message { ulong timestamp; } Message LongMessage { ubyte[255] s; } // // it mean // // struct LongMessage // { // Message _super; // alias _super this; // ubyte[255] s; // } // // or // // struct LongMessage // { // ulong timestamp; // ubyte[255] s; // } ``` Is it possible?No, there's no struct inheritance. But you can just write the `alias this` version manually.
Sep 17 2023