Can we disallow appending integer to string?
Nick Treleaven via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Apr 21 01:36:12 PDT 2017
On Thursday, 20 April 2017 at 11:05:00 UTC, Nick Treleaven wrote:
> On Wednesday, 19 April 2017 at 14:50:38 UTC, Stanislav Blinov
> wrote:
>> Because integrals implicitly convert to characters of same
>> width (byte -> char, short -> wchar, int -> dchar).
>
> Despite char.min > byte.min, char.max < byte.max.
The above mismatches would presumably be handled if we disallow
implicit conversion between signed/unsigned
(https://issues.dlang.org/show_bug.cgi?id=12919).
> I would like to see some small changes to mitigate against
> things like this, even if we can't agree to prevent the
> conversion overall.
It seems there's a strong case for preventing the int -> dchar
conversion. wchar.max == ushort.max, char.max == ubyte.max, but
dchar.max < uint.max.
Converting from char types -> integers, whilst (arguably) bug
prone, at least is numerically sound. So perhaps we could
disallow uint -> dchar, which is unsound.
More information about the Digitalmars-d-learn
mailing list