size_t index=-1;
tsbockman via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Mar 16 19:20:44 PDT 2016
On Thursday, 17 March 2016 at 01:57:16 UTC, Jonathan M Davis
wrote:
> Just assigning one to the other really isn't a problem, and
> sometimes you _want_ the wraparound. If you assume that it's
> always the case that assigning a negative value to an unsigned
> type is something that programmers don't want to do, then you
> haven't programmed in C enough.
Greater than 90% of the time, even in low level code, an
assignment, comparison, or any other operation that mixes signed
and unsigned types is being done directly (without bounds
checking) only for speed, laziness, or ignorance - not because
2's complement mapping of negative to positive values is actually
desired.
Forcing deliberate invocations of 2's complement mapping between
signed and unsigned types to be explicitly marked is a good
thing, seeing as the intended semantics are fundamentally
different. I interpret any resistance to this idea, simply as
evidence that we haven't yet made it sufficiently easy/pretty to
be explicit.
Any idea that it's actually *desirable* for code to be ambiguous
in this way is just silly.
More information about the Digitalmars-d-learn
mailing list