I am currently reading a draft of the C11 specification. The new introduced keywords: _Bool, _Alignof, _Atomic
all feel like custom extensions, instead of standard reserved keywords like struct, union, int
.
I realize that the standard basically consists of standardized extensions … but still, this is awful! Maybe we will soon end up with __Long_Long_Reallylong_Integer_MSVC_2020_t
creeping in the standard!
Is the backward compatibility of nonstandard code the only reason of the new style of the keywords?
2
I imagine that backwards compatibility with perfectly standard code is a more important reason.
If you add a keyword that might have been used as a legitimate identifier in previous code, you create a ton of pain, of possible subtle errors, especially in C, a language with somehow complicated parsing rules.
If these identifiers were used as a public interface somewhere, you add pain to all users of such unfortunate libraries, who might not use C at all, but call the library from Ruby, or Python, etc.
That’s why new keywords are bound to look less like nice words and more like bolt-on hacks that people have smaller chances of already using for another purpose.
11
Names beginning with an underscore and a capital letter (and anything with double underscore) were reserved for compiler/standard library implementation in previous standards.
From Reserved Identifiers of C89 and C99:
Also reserved for the implementor are all external identifiers
beginning with an underscore, and all other identifiers beginning with
an underscore followed by a capital letter or an underscore.
So in theory, those new keywords should not be in use in any code writen before and that leads to better backward compatibility than any simple name, which is likely the only reason.
1