On Tuesday, 24 February 2026 at 21:37:44 UTC, Kapendev wrote:
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.

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`.

If Im dropping the concept of different layouts, its safe and doesnt need the abstraction and not repeating myself defining the fields.

Reply via email to