fat struct style guide?

Julian Fondren julian.fondren at gmail.com
Tue Feb 24 22:11:36 UTC 2026


On Tuesday, 24 February 2026 at 21:56:47 UTC, monkyyy wrote:
> only with a pretty void* cast is accessing a tagged union field 
> that happens to line up 0 indirection, everyone here is going 
> to tell me to do the safe then and write an abstracted getter 
> that gets the .offsetof `age`.

Some other options: using a common struct member for the common 
cases, and rotating the struct so that you have a 
struct-of-arrays (SoA) instead of an array of structs. Whether 
these are wins depends on what you're doing exactly. If the 
variants have very different fields, SoA stops making sense fast. 
But to add 10 all the ages you would have a function that 
modifies an int[]


More information about the Digitalmars-d-learn mailing list