views:

144

answers:

3

Possible Duplicate:
The written versions of the logical operators.

I notice that C++ define keyword and, or, not, xor, and_eq, or_eq, not_eq and xor_eq as an alternative to &&, ||, !, ^, &=, |=, != and |=. and they're rarely used! What's wrong? Are they not portable?

+3  A: 

Portable. They are defined in the standards.

See this answer.

KennyTM
A: 

They are just more verbose and more prone to generate unreadable code. I think. But they are portable.

Klaim
I disagree. How are these unreadable? (Downvote not by me, btw.)
KennyTM
I wouldn't say they're unreadable (except perhaps by non-English speakers) but they are unfamiliar. Most C++ programmers are used to seeing `||` and such, so they might pause for a second and go "Wait... really?" Maybe that's what you meant?
MatrixFrog
yes i think it was more clear, isn't? its just a matter of most people just getting used to see the symbol, aside of that its good i say (downvote not by me too)
uray
The keyword operators blend with the surrounding text much more easily than symbol operators (in fact, Visual Studio colors them as identifiers), which is why I'd consider them unreadable, or at least less readable, as well. +1
avakar
yes that's weird for most C++ editor, i used to make those keyword operator as user defined keyword in Visual Studio in order to make them colored as a real keyword, should we consider it as a bug to visual studio?
uray
@uray, I'd consider it a bug in the C++ standard. The keywords should be at least deprecated.
avakar
It cannot be deprecated if it's not in C I guess.Anyway, I think it generate unreadable code because blended with several expressions makes it sometime hard to separate them (as most words used in tests are variables and functions). I added "I think" to reflect the subjective side of my "assertion".
Klaim
Klaim, I didn't quite understand. What do you mean by "cannot be deprecated if it's not in C"?
avakar
I mean that almost all C features (not all but almost) have to be supported by C++. If it's still in the C standard today and it's not against some fundamental way of thinking of C++, then C++ will have it too.
Klaim
+2  A: 

They come from C AFAIR from times when it was not known what special symbols are on the keyboard. So to have portable language they were defined so anyone can use C even if (s)he used keyboard with no &, | or ^ (etc.).

Nowadays when QWERTY is a standard (with AZWERTY & co. as variations) it is no loner an issue.

PS. And of course obfuscation code competitions ;)

Maciej Piechotka