On Monday, 18 April 2016 at 02:12:24 UTC, Tofu Ninja wrote:
Just out of curiosity, what is the point of the following?
struct a{
struct{
int x;
int y;
int z;
}
}
The grouping matters when it is nested inside a union. Here's a
real world example:
https://github.com/adamdruppe/arsd/blob/master/color.d#L128
The anonymous struct inside the union allows me to say that
r,g,b, and a are NOT supposed to share memory, but rather give
structure to the shared uint or ubyte[4] in the other union
members.
My documentation generator also uses the grouping to add shared
docs for the innards:
http://dpldocs.info/experimental-docs/arsd.color.Color.__anonymous.html
(I'm not terribly happy with giving it the name `__anonymous` in
the docs but I didn't have any better idea yet.)
Though that isn't a feature of D itself, I do find it nice to be
able to group documentation.
The struct inside union is the main pure-language use case I know
of though.