Quick A: To avoid breaking old code, thanks to context-sensitive keywords.
Recently on SO:
Why are override and final identifiers with special meaning instead of reserved keywords?
Both the override specifier and final specifier were added in C++11. They differ from other specifiers added to C++11 such as constexpr and decltype, in that they are not keywords and so are available for use as identifiers:
int main() { int override = 0 ; // Ok int final = 0 ; // Ok //int constexpr = 0 ; // Error }They are referred to as identifiers with special meaning, which is covered in the draft C++11 standard section 2.11 [lex.name] (emphasis mine):
The identifiers in Table 3 have a special meaning when appearing in a certain context. When referred to in the grammar, these identifiers are used explicitly rather than using the identifier grammar production. any ambiguity as to whether a given identifier has a special meaning is resolved to interpret the token as a regular identifier.
and Table 3 -- Identifiers with special meaning lists both override and final.Why did these two specifiers end up being identifiers with special meaning instead of keywords?
Add a Comment
Comments are closed.