Treating the abusive unsigned syndrome

Sean Kelly sean at invisibleduck.org
Wed Nov 26 11:17:27 PST 2008


Andrei Alexandrescu wrote:
> 
> Notice that the fact that one operand is a literal does not solve all of 
> the problems I mentioned. There is for example no progress in typing u1 
> - u2 appropriately.

What /is/ the appropriate type here?  For example:

     uint a = uint.max;
     uint b = 0;
     uint c = uint.max - 1;

     int  x = a - b; // wrong, should be uint
     uint y = c - a; // wrong, should be int

I don't see any way to reliably produce a "safe" result at the language 
level.


Sean



More information about the Digitalmars-d mailing list