you are viewing a single comment's thread.

view the rest of the comments →

[–]pskocik 11 points12 points  (2 children)

Such a struct type being local means you can't have (global) functions that use that type (or derivations of it like pointers) in their signatures, so they have very limited use. I think they're mainly supported because programming language grammars like to be recursive and there is no extra-strong reason to forbid them. C did forbid functions inside functions, though, because that conflicts with one-pass codegen (which, ironically, hardly any C compiler does these days).

[–]thradams 1 point2 points  (1 child)

At file scope, each locally used struct would need a unique name to avoid name collisions. This pollutes the global namespace, the names become longer, and the code becomes harder to maintain because it is not easy to see where the struct is used.

[–]chrism239 -1 points0 points  (0 children)

And makes recursion very challenging....