On Tuesday, 30 January 2018 at 11:09:08 UTC, Michael wrote:
On Monday, 29 January 2018 at 10:06:41 UTC, Jonathan M Davis
wrote:
On Monday, January 29, 2018 09:58:00 Dave Jones via
Digitalmars-d wrote:
Given
uint i = 12345;
should
writeln(-i)
be an error? or maybe i should be automatically cast to a
larger signed type?
It arguably should be, but it's pretty common in C/C++ to get
uint.max with -1, and I suspect that it's fairly common in D
as well even though you could just use uint.max. So, it could
be argued either way.
- Jonathan M Davis
I'd like to see these kinds of potential mistakes to be forced
to use something like uint.max. Of course, at this point it
might be too late to introduce something as breaking as this,
but these kinds of things should definitely be forced by the
language, or made a warning at least, pointing to the use of
.max instead.
A normal deprecation process should be enough, since it'll give
time to update code that uses it.
I don't think there is a lot of idiomatic D code that uses this
feature.