News for hackers. Stuff that matters.
Re:What XOR is and why it's useful by jjice on Tuesday February 18, 2025 @04:18PM (#43095240)
One of my favorite XOR stories is from Bryan Cantrill (of Oxide, Joyent, and Sun) in this presentation [0] and this video [1].

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

Re:What XOR is and why it's useful by wat10000 on Tuesday February 18, 2025 @04:30PM (#43095353)
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 `!!`.
Re:What XOR is and why it's useful by wslh on Tuesday February 18, 2025 @09:39PM (#43097943)
^ ?
Re:What XOR is and why it's useful by 201984 on Tuesday February 18, 2025 @10:05PM (#43098104)
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).
Re:What XOR is and why it's useful by gblargg on Wednesday February 19, 2025 @06:52AM (#43101097)
No need for the second !: !foo != !bar
Re:What XOR is and why it's useful by wat10000 on Wednesday February 19, 2025 @08:47AM (#43102089)
True, but you might confuse people if you use a nonstandard construct like this.
Re:What XOR is and why it's useful by snvsn on Tuesday February 18, 2025 @05:24PM (#43095885)
Topic starts at 37:18
Re:What XOR is and why it's useful by kjs3 on Tuesday February 18, 2025 @09:49PM (#43098003)
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?

Re:What XOR is and why it's useful by gblargg on Wednesday February 19, 2025 @06:54AM (#43101102)
There wouldn't be any advantage to adding a boolean exclusive or operator, unlike with || and &&.