Deprecate `!a == b`

IchorDev zxinsworld at gmail.com
Wed Aug 14 18:19:00 UTC 2024


On Wednesday, 14 August 2024 at 15:41:13 UTC, Dennis wrote:
> On Wednesday, 14 August 2024 at 15:04:13 UTC, IchorDev wrote:
>> I feel like integer promotion is a much more pressing issue in 
>> that department. It’s one of the few things I wish we’d just 
>> bin because it’s so atrocious.
>
> Oh, I thought the list represented things you _didn't_ want to 
> see in the language. But your point is rather that D is not 
> consistent about this kind of error prevention?

What? No, I literally said that the only thing in that list that 
I’d want in the language is the null cast thing, which is 
impossible to do. I also stated separately that in an ideal world 
we’d **completely remove** integer promotion. In the list, the 
idea was that the compiler would force you to manually write a 
cast whenever and wherever the compiler decides to promote an 
integer, which would be an abomination:
```d
short x = 1, y = 2;
int z = x + y; //warning: integer promotion must be explicit
int w = cast(int)x + cast(int)y;
int ohNo = cast(int)x * cast(int)x + cast(int)y * cast(int)y + 
z*z + w*w;
```

>> And personally I’ve been screwed over by arithmetic operator 
>> precedence on many occasions.
>
> Same, which is why I often defensively parenthesize expressions 
> with binary operators.

I do that less and less. I think that learning the precedence and 
omitting the parenthesis makes the code a lot easier to 
sight-read. The tipping point for me is about 3 nested 
parenthesis, after which they all start to blur together.


More information about the dip.ideas mailing list