disabling unary "-" for unsigned types
Walter Bright
newshound1 at digitalmars.com
Thu Feb 18 11:22:06 PST 2010
Steven Schveighoffer wrote:
> First, it would work under my rules. j would be of type int. Under my
> rules, negating an unsigned value equates to a signed version of that
> type.
I've tried to stick with the principle that C code compiled with D will
either work the same, or will fail with a compiler error message. It's
very important to avoid "compiles, but produces subtly different
behavior" for integer numeric code.
The reason for this is there's a lot of debugged, working C code that
contains rather complicated integer expressions. How/why it works may be
long since lost information, and having it fail when translated to D
will cause frustration and distaste for D.
Changing the signedness of a sub-expression will definitely fall into
this category.
More information about the Digitalmars-d
mailing list