On Sunday, 28 September 2025 at 00:25:41 UTC, Paul Backus wrote:
> If you have complex nested types that are multiple layers deep, you should probably be separating those layers into their own named structs anyway rather than defining everything inline.
Honestly, even if we had built-in tuples, I would prefer to write your original example like this:
I think the example with 'point' is too small to represent a realistic use case for this feature, so I want to provide a real struct example to make it easier to discuss. This code is copied directly from my code which parses a .json file of a font atlas generated by msdf-atlas-gen:
struct FontJson
{
Atlas atlas;
struct Atlas
{
double size; // pixels per em
int width;
int height;
Grid grid;
struct Grid
{
int cellWidth;
int cellHeight;
int rows;
int columns;
double originY = 0;
}
}
Metrics metrics;
struct Metrics
{
double ascender = 0;
double descender = 0;
double underlineY = 0;
double underlineThickness = 0;
}
Glyph[] glyphs;
struct Glyph
{
int unicode;
double advance = 0;
struct PlaneBounds
{
double left = 0;
double top = 0;
double right = 0;
double bottom = 0;
}
PlaneBounds planeBounds;
struct AtlasBounds
{
double left = 0;
double top = 0;
double right = 0;
double bottom = 0;
}
AtlasBounds atlasBounds;
}
struct Kerning
{
int unicode1;
int unicode2;
double advance = 0;
}
Kerning[] kerning;
}
I don't think it's too bad currently, but I can see anonymous structs being useful here. I wouldn't replace the structs with tuples though. I also don't really want to flatten the nesting, I like how the nested structs model the json structure very closely, and don't want the structs to be used outside the JSON parsing.