fat struct style guide?
Julian Fondren
julian.fondren at gmail.com
Tue Feb 24 19:56:38 UTC 2026
On Tuesday, 24 February 2026 at 19:01:35 UTC, monkyyy wrote:
> Consider the `old` function, a tagged union would add a layer
> of indirection that does nothing.
```d
enum animalid{cow=7,chicken,horse};
struct animal{
animalid id;
string say;
int age;
}
```
This is a tagged union. Both the D and the Nim that I posted have
a check against the tag that's technically unnecessary, but what
you're doing here is like saying that you don't want to use
arrays "because array indexing comes with an array bounds check
and that slows down access".
More information about the Digitalmars-d-learn
mailing list