disabling unary "-" for unsigned types

dsimcha dsimcha at yahoo.com
Sun Feb 14 13:37:48 PST 2010


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> ulong x0;
> static assert(!__traits(compiles, -x0));
> uint x1;
> static assert(!__traits(compiles, -x1));
> ushort x2;
> static assert(!__traits(compiles, -x2));
> ubyte x3;
> static assert(!__traits(compiles, -x3));
> Sounds good?
> Andrei

The more you bring up features to give the axe to, the more I find it funny that,
not being a very good language lawyer, I wasn't aware that half of these features
existed in the first place.  This is one of them.  Yes, definitely get rid of it.
 It makes absolutely no sense.  If you want to treat your number like a signed
int, then it should require an explicit cast.



More information about the Digitalmars-d mailing list