Providing implicit conversion of
Steven Schveighoffer
schveiguy at gmail.com
Mon Jan 22 01:14:06 UTC 2024
On Sunday, 21 January 2024 at 16:05:40 UTC, Gavin Gray wrote:
> The following code:
>
> ulong charlie = 11;
> long johnstone = std.algorithm.comparison.max(0, -charlie);
> writeln(format!"johnstone %s"(johnstone));
>
> Results in (without any warning(s)):
> johnstone -11
>
> However you choose to look at it, this means -11 > 0
> (regardless of all arguments concerning implicit conversions,
> 1's and 2's complements, being efficient, etc).
>
> The language should not allow unary unsigned anything.
This is unlikely to get fixed, just due to the nature of D's
philosophy when it comes to C compatibility.
It would also break a lot of existing code.
-Steve
More information about the Digitalmars-d-learn
mailing list