Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"Sadly XOR doesn’t appear as an equivalent to NOT, AND and OR, as a logical operator on booleans, being relegated to just a bitewise operator in most programming languages."

Well, in C there's just no need. The main raison d'etre for && and || over & and | is that you can exploit their short circuiting behaviour. A hypothetical ^^ operator wouldn't bring anything extra to the table.



It might at least coerce its operands to bool. As things are, 2&&1 is true, and 2&1 is false; hypothetically, 2^^1 could be false while 2^1 would be (as now) true.


The real problem is that you can not short circuit with XOR.


You have to evaluate both arguments to a XOR op to know its result. Short circuiting it has no natural meaning.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: