Home >Backend Development >C++ >Do C 's 'and' and 'or' Tokens Offer a Functional Alternative to '&&' and '||'?
The Introduction of "and" and "or" Alternative Tokens in C
In a recent Reddit discussion, the existence of "and" and "or" alternative tokens to "&&" and "||" in C surfaced, raising questions about their origins and availability.
History of Alternative Tokens
As explained in the ISO C 98 standard (2.5/ Alternative tokens), alternative token representations have been provided for certain operators and punctuators since its inception. These alternative tokens, including "and" and "or," behave identically to their primary tokens except for their spelling.
Availability of Alternative Tokens
Based on the provided information, the alternative tokens for "and" and "or" have been available since the earliest days of the C standardization process. However, their use has been limited due to the wider availability of the full character set in most modern environments.
Reason for Obscurity
The obscurity of these alternative tokens can be attributed to their historical use cases. In the past, they were primarily used in environments where the full character set was not available. For instance, the EBCDIC character set used on IBM mainframes lacked the square bracket characters ("[" and "]") used to represent the "and" and "or" operators. Thus, the alternative tokens "and" and "or" served as workarounds in such scenarios.
Conclusion
While the alternative tokens "and" and "or" have existed in the C language since its early standardization, they have remained relatively obscure due to the widespread availability of the full character set. Visual C 2008 does not recognize these tokens as anything other than syntax errors, reflecting their limited practical usage.
The above is the detailed content of Do C 's 'and' and 'or' Tokens Offer a Functional Alternative to '&&' and '||'?. For more information, please follow other related articles on the PHP Chinese website!