Deprecate implicit conversion between signed and unsigned integers

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Fri Feb 7 04:26:31 UTC 2025


On 07/02/2025 9:55 AM, Walter Bright wrote:
> I forgot to mention:
> 
> ```
> int popcount(int x);
> ```
> ```
> uint y = ...;
> popcount(y);   // do you really want that to fail?
> ```
> 
> Let's fix it:
> 
> ```
> int popcount(uint x);
> ```
> ```
> int y = ...;
> popcount(y);   // now this fails
> ```

Within the last couple of days on Twitter the C community has mentioned 
that they'd like implicit conversion for numeric types to static arrays.

That could resolve this quite nicely.

```d
int popcount(ubyte[4]);

int y = ...;
popcount(y);

uint z = ...;
popcount(z);
```

An explicit cast with ``ref`` could go the other way.



More information about the dip.ideas mailing list