Can we just have struct inheritence already?
rtcvb32 at yahoo.com
Tue Jul 2 04:54:07 UTC 2019
On Sunday, 9 June 2019 at 08:05:34 UTC, Manu wrote:
> Imagine if we could just write:
> struct DerivedStruct : BaseStruct
> // derived members
> Just imagine!
I'd think struct inheritance would follow the original C++'s
1) No Virtual functions. All functions are FINAL (replacing)
2) No polymorphism.
3) Limited casting (Casting up/back is easier than casting down,
with space limitations in mind), though casting could simply be
disallowed but that seems unlikely when you get low level.
In such a case you could build a base struct and then add onto
it for several structs behaviors. Being able to avoid using the
GC as much as possible that would help. Also most of the
functions/structures are basically copy/pasted with overriding
functions completely replacing the previous ones.
I've been wanting this for a while. I had a prototype set of
templates to do this very thing! But... it no longer works,
hasn't since... oh i don't remember. I'd have to pull the old
I'd probably ask a debugging feature where you could output the
new finalized struct in it's full source code or maybe rather
just it's API specifying what functions/variables come from
where, so you get a clear picture of what you're working with if
you inherit several times/deep.
More information about the Digitalmars-d