The written versions of the logical operators

In C++, they are real keywords. In C, they're macros defined in <iso646.h>. See http://web.archive.org/web/20120123073126/http://www.dinkumware.com/manuals/?manual=compleat&page=iso646.html.


They do exist for usability (character support in keyboard/display flavors) and general readability, but there's another reason that's nowadays more pronounced. Almost none of the answers here, here, or even the main answer here spell out the core reason many of us prefer the word versions over the symbol versions (and a main reason other languages use them): bugs. The differences between the word versions are very visible. The differences between the symbol versions are markedly less so, to the point of tempting bugs to a comparatively much greater extent: "x|y" is very much not "x||y", yet when embedded in a larger expression many of us miss the difference. It's similar to the common accidental mixing of the assignment vs equality operator. For this reason I've weaned myself off of the symbol versions (it wasn't easy) in favor of the word versions. I'd rather have someone do a double-take on them due to our love of old things than tempt bugs.


They originated in C in the header <iso646.h>. At the time there were keyboards that couldn't type the required symbols for && (for example), so the header contained #define's that would assist them in doing so, by (in our example) defining and to be &&. Of course, as time went by this became less used.

In C++, they became what are known as alternate tokens. You do not need to include anything to use these tokens in a compliant compiler (as such, the C++-ified version of the C header, <ciso646>, is blank). Alternate tokens are just like regular tokens, except for spelling. So during parsing and is exactly the same as &&, it's just a different way of spelling the same thing.

As for their use: because they are rarely used, using them is often more surprising and confusing than it is helpful. I'm sure if it were normal, they would be much easier to read, but people are so used to && and || anything else just gets distracting.

EDIT: I have seen a very slight increase in their usage since I posted this, however. I still avoid them.