Deprecate `!a == b`

Dennis dkorpel at gmail.com
Tue Aug 13 21:13:17 UTC 2024


On Tuesday, 13 August 2024 at 20:30:10 UTC, IchorDev wrote:
> But I’ve also never seen anyone think this would work?

It's easy to have a lapse of focus. Last hour, I accidentally 
used `&&` for bit masking instead of `&`. I also sometimes write 
`if (x = 3)` by mistake, or forget a `return` statement like this:

```D
bool f(int x)
{
     x == 3;
}
```

Luckily the D compiler catches these. It's not that I thought 
these things would work in D, but simple human error.

It's also worth noting that things are different in other 
programming languages. In some languages the last expression is 
automatically returned. And in Python, the order of operations 
makes `!a == b` actually work like most (new) programmers intend:

> python
>>> not (3 == 4)
True
>>> not 3 == 4
True
>>> (not 3) == 4
False
```



More information about the dip.ideas mailing list