Comment by int_19h

10 hours ago

What I don't quite get is why they didn't go all the way in and basically enabled full fledged structural typing for anonymous structs.

That way my plan, but the committee had concerns about type safety.

  • This would probably need some special rules around stuff like:

       typedef struct { ... } foo_t;
       typedef struct { ... } bar_t;
       foo_t foo = (bar_t){ ... };
    

    i.e. these are meant to be named types and thus should remain nominal even though it's technically a typedef. And ditto for similarly defined pointer types etc. But this is a pattern regular enough that it can just be special-cased while still allowing proper structural typing for cases where that's obviously what is intended (i.e. basically everywhere else).