The most beautiful about standards is that there are so many. When reading the C++11 standard compared to the CLI-Standard (5th edition), I’m getting a little bit confused about the identifier naming.
Where C++ allows according [ISO/IEC 14882:2011 page 23] ASCI: _a-zA-Z0-9 (regardless the order) and according [page 1249] A lot of unicode characters .. there is no definition for $ (0x24). On the other hand [ECMA335 partition II page 13] allows a-zA-Z0-9_``@$ as identifier-characters.
In other words C++ shouldn’t support $ (0x24) inside identifier names, but the CLR should. When testing this i’ve noticed exactly the opposite:
- native C++ (native MSVC [of VS2010 Ultimate], GCC [2.8.1], minGW [latest]) supports
$; - C++\CLI or even C# (MSVC) doesn’t support
$.
So what is the truth? Am I missing something when reading the standards? Or is everybody doing what he wants to do?
A complication is that section 2.2 says:
So we formally don’t know that the
$in the source file corresponds to a dollar sign in the identifier. It just might be mapped to something else.The requirements in the language standard is also a minimum what an implementation must provide. All compilers provide extensions to the standard language. Allowing extra characters in identifier names might be such an extension, possibly to support old pre-standard code or some OS specific features.