fat struct style guide?
user1234
user1234 at 12.de
Thu Feb 26 18:39:40 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. This wont be faster, it may
> only tie if the compiler untangles the mess that was made.
>
> A 3d engine will have lots of things, but then have a draw loop
> that like "I dont care whats your model id and position"
I see.. I thought to my reply yesterday and saw how unperfect it
was. What I mean is really like when you have to deal with a lot
of let'say base "Object"s then a tag can be faster than a dynamic
cast. Problem is we cant really merge struct members...so even
with the tag there's might be indirections, compared to using a
tag for class casts. I hope this is clearer now.
More information about the Digitalmars-d-learn
mailing list