Home >Backend Development >C++ >When Were C 's 'and' and 'or' Tokens Introduced?
Alternative Tokens: Quand Were the 'and' and 'or' Tokens Introduced in C ?
The recent Reddit post on alternative tokens, notably 'and' and 'or,' has sparked curiosity among developers. These alternative tokens, often overlooked, have been part of the C language since its inception.
What Are Alternative Tokens?
In C , alternative tokens are alternative representations for certain operators and punctuators. For instance, 'and' is an alternative token for '&&', and 'or' is an alternative for '||'.
When Were They Introduced?
Contrary to assumptions, alternative tokens have been present in the C standard since its first iteration, C 98. They are explicitly mentioned in the ISO C 98 specification under Section 2.5/ Alternative tokens [lex.digraph].
Why Are They Underused?
Despite their long history, alternative tokens remain relatively unknown among programmers. One reason for this is that their primary use case was for environments where the full character set was not available. For example, older versions of IBM's EBCDIC character set lacked the square brackets '[' and ']' characters, leading to the use of alternative tokens ':<' and ':>' instead.
Compatibility Note:
Visual C 2008 does not recognize 'and' and 'or' as valid tokens. This is because Microsoft did not implement this feature in their early Visual C compilers. To use alternative tokens in modern C compilers, simply update to a more recent version.
The above is the detailed content of When Were C 's 'and' and 'or' Tokens Introduced?. For more information, please follow other related articles on the PHP Chinese website!