Vladimir wrote:

Why there is no logical xor operator?

To compute the result of XOR, you have to evaluate both operands.

For evaluating both operands with a sequence point in between, there

already exists the comma operator.

The virtue of && and || is that they perform short-circuited

left-to-right evaluation. They are not just logical functions, but

evaluation-controlling operators.

I often miss it in mutually-exclusive if-statements.

XOR is not as useful as you might think in testing for mutually

exclusive alternatives.

The result of a binary XOR, if true, tells you that exactly one of the

two constituents is true. But a nested XOR among three or more

constituents does not compute that: it computes that an odd number of

the terms is true!

If you have N logical expressions, where N > 2, and you want to test

that exactly one of them is true, you need a specially-designed,

variable-argument XOR.

But note that the binary && and || operators do combine in a useful

way. If you had an && that could take three or more operands, it would

be equivalent to a nesting of multiple binary && operators.

So in other words:

A && B && C && D

does the intuitive thing. It keeps evaluating the terms left to right

until it finds one that yields true.

What would it mean to write:

A ^^ B ^^ C ^^ D

It would have to evaluate all of the terms: no short circuiting. And

the return value would be true if any odd number of these terms yielded

true: if exactly one term is true, or if any three are true.