Can we just have struct inheritence already?

Vladimir Panteleev thecybershadow.lists at gmail.com
Sun Jun 9 19:40:24 UTC 2019


On Sunday, 9 June 2019 at 19:04:50 UTC, Nick Sabalausky 
(Abscissa) wrote:
> I'm not even entirely sure what's going on in the "static else" 
> there. Is it just saying:
>
> "If the BaseStruct is all methods and no data, then don't 
> bother letting `BaseStruct base` add extra obviously-never-used 
> bytes in DerivedStruct?"
>
> If so, it sounds like maybe that's an optimization the 
> language/compiler could/should be doing (semi-?)automatically?

Structs are always at least 1 byte in size, even when they 
contain no fields. This causes unnecessary bloat for reasons that 
I never understood.



More information about the Digitalmars-d mailing list