fat struct style guide?

Kapendev alexandroskapretsos at gmail.com
Tue Feb 24 21:37:44 UTC 2026


On Tuesday, 24 February 2026 at 19:01:35 UTC, monkyyy wrote:
> On Tuesday, 24 February 2026 at 18:49:58 UTC, user1234 wrote:
>> On Tuesday, 24 February 2026 at 16:56:57 UTC, monkyyy wrote:
>>> [...]
>>
>> The tagged union approach is actually faster when you deal 
>> with a situation such as
>>
>> - you only care about final types
>> - your final types have several bases
>> - you would cast a lot
>> - you don't care about nicely looking declarations (e.g SDL 
>> event, XEvent, etc 🤢)
>
> Consider the `old` function, a tagged union would add a layer 
> of indirection that does nothing.

You get the same type of indirection with a "mega struct" if we 
are talking about type checking.
And you will be checking types often in a game.
There is literally no difference in how a tagged union and a mega 
struct works if you create a union with members that all share 
the same first field.
The only difference will be the size, with tagged unions being 
smaller and faster to iterate over.



More information about the Digitalmars-d-learn mailing list