Deprecate implicit conversion between signed and unsigned integers

Paul Backus snarwin at gmail.com
Wed Feb 5 16:29:25 UTC 2025


On Tuesday, 4 February 2025 at 16:29:22 UTC, Quirin Schroll wrote:
> Any implicit conversions? I’d boldly claim the following 
> conversions are unproblematic:
> * `float` → `double` → `real`
> * signed integer → bigger signed integer
> * unsigned integer → bigger unsigned integer
>
> And it would be really annoying to have to explicitly cast them.

In general, implicit conversions that preserve the value range of 
the original type are ok. So, for example:

* `ushort` → `int`
* `long` → `float`

The reason that conversions like `int` → `uint` and `uint` → 
`int` are problematic is that the value range of the original 
type does not fit into the value range of the target type.


More information about the dip.ideas mailing list