Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How would using an existing structure definition where an undefined type is found break anything?

Compilers already know what you want to do as it will print an error such as: "unknown type name ‘Vec’; use ‘struct’ keyword to refer to the type".



So you want Vec to refer to struct Vec but only if there is no other type Vec defined before or until one is defined later? That would work, but might be a bit confusing.


C++ has struct & typedef and things work quite naturally. It always seemed like an obvious thing to bring to C, but I'm not sure about the nuances of the rules governing this.


C++ had this forever (I assume), but for C this would be a breaking change which we try very hard to avoid.


Could you please give an example of what would break? Perhaps I'm being dense, but it seems a new C standard supporting this would still compile existing code just as C++ can.


In C, it's perfectly legal to do this:

    struct S { ... };
    typedef int S;
That's not valid in C++ (so would be a breaking change in C, if it were to adopt this).

I don't really think changing this in C would break all that much code, but it's definitely not backwards compatible.


That's how it works for an object's attributes inside methods, since this is optional by default. I hate it but there's precedent.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: