Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Why isn't there a logical XOR operator?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Arthur J. O'Dwyer, post: 1699625"] *Nobody* is suggesting changing the short-circuiting semantics of && or ||. But several people *are* suggesting the addition of a third logical operator, ^^, which performs a logical XOR on its two operands (after converting them to "boolean" 0 or 1). The logical XOR, naturally, cannot short-circuit; there's nowhere for it to short-circuit "to," if you get my drift. However, that fact has nothing to do with the short-circuiting or not of && and ||. & : Computes the bitwise AND of its operands. | : Computes the bitwise OR of its operands. ^ : Computes the bitwise XOR of its operands. && : Computes the logical AND of its operands in an efficient left-to-right manner. || : Computes the logical OR of its operands in an efficient left-to-right manner. ^^ (proposed): Computes the logical XOR of its operands in an efficient left-to-right manner. So AIUI, the logical XOR operator would introduce a sequence point between the evaluation of its operands (which incidentally none of the suggested remedies do), and it would compute the answer in a manner "as short-circuited as possible" -- i.e., not short-circuited at all. As the fact that ^^ cannot short-circuit is apparent to anyone with the ability to think, I don't think its not short-circuiting is likely to confuse anyone with the ability to program. :-) [Again: I'm a supporter of the status quo out of pessimism, but I will attempt to demolish arguments that support the status quo by reasoning alone -- because I think the omission of ^^ *was* a bad idea. Why hack up solutions involving != when what the algorithm demands is a logical XOR? (...Because that's the only way the language supports, is why. No deeper reason.) ] -Arthur [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Why isn't there a logical XOR operator?
Top