Deprecate `!a == b`

Quirin Schroll qs.il.paperinik at gmail.com
Wed Aug 28 21:39:43 UTC 2024


On Wednesday, 14 August 2024 at 14:36:50 UTC, Dennis wrote:
> Whether `!a == b` is such a case depends. You apparently have 
> seen intentional use, so it makes sense you judge it as not 
> worth adding an error for. I'm actually curious, can you link 
> to real code using that pattern intentionally?

I can’t link something, but I have definitely written something 
like that at some point to implement a XOR for bools. There are 
loads of situations where you need to test that two bools are 
equal or unequal and `!a == b` is a way to say `a != b`. It’s not 
a good way, granted, but I can definitely see why beginner me 
would have written that: `a != b` could compare anything, `!a == 
b` compares bools. What I’m saying is not that it’s good code, 
but not wildly unrealistic code either. The language keeping 
someone from writing that is a good thing. It’s in the same 
ballpark as `x => {}` not being allowed.


More information about the dip.ideas mailing list