disabling unary "-" for unsigned types

Ellery Newcomer ellery-newcomer at utulsa.edu
Mon Feb 15 17:56:02 PST 2010


On 02/15/2010 05:33 PM, Steven Schveighoffer wrote:
>
> i.e.
>
> uint a = -1; // error

I can't say I would appreciate having to write

uint a = 0xFFFFFFFF;

or the equivalent for ulong.

> uint b = 5;
> uint c = -b; // error
> int d = -b; // ok
> auto e = -b; // e is type int
>
> In the case of literals, I think allowing - on a literal should require
> that it be assigned to a signed type or involve a cast.
>
> -Steve




More information about the Digitalmars-d mailing list