C does have a logical XOR, it's the `!=` operator. Unlike other logical operators, it requires the arguments to be normalized to a single truth value. It plays nicely with C's convert-to-boolean operator `!!`.
^ ?
That's bitwise, not logical.
Re:What XOR is and why it's useful
by 8n4vidtmkvmk on Tuesday February 18, 2025 @10:09PM
(#43098128)
That's bitwise xor
Re:What XOR is and why it's useful
by Findecanor on Wednesday February 19, 2025 @02:57AM
(#43099757)
I once failed a a test at a job interview because I hadn't realised that (even after having been programming for twenty years).
No need for the second !: !foo != !bar
True, but you might confuse people if you use a nonstandard construct like this.
Topic starts at 37:18
DMR was remarkably kind, helpful and accessible. As an undergrad in the mid 80s I read about 'the first' port of Unix (v6) to something other than a PDP-11, the Interdata 8/32. On a whim, I sent an email to [email protected] (might have even been back as far as research!dmr or [email protected]) asking if there was more info about the architecture as 1) no google and 2) nothing in the uni library. A couple of days later he responded and asked for my (physical) address. A few weeks later, a copy of the instruction set summary manual showed up in my (physical) mailbox. It's IBM 360-ish. Still have it.
Re:What XOR is and why it's useful
by penguin_booze on Wednesday February 19, 2025 @02:13AM
(#43099461)
> Faulkner said it was because you couldn't short circuit it
I don't get it. Why is that an impediment to adding an operator? Can some one elaborate?
To avoid clicking a link: When he was at Sun, he was chatting with a coworker (Roger Faulkner) about the lack of logical XOR in C. Faulkner said it was because you couldn't short circuit it, and Brian thought that was wild. Then Roger emailed Dennis Ritchie to ask and he confirmed it was what Faulkner had said.
That stories gets me every time! First of all, it's very funny and well delivered by Cantrill, but it's also just so incredible that they could ask the man himself.
[0] https://speakerdeck.com/bcantrill/oral-tradition-in-software...
[1] https://www.youtube.com/watch?v=4PaWFYm0kEw