yank '>>>'?

Walter Bright newshound1 at digitalmars.com
Sun Dec 6 12:08:12 PST 2009


Andrei Alexandrescu wrote:
> D has operator >>> which means "unsigned shift to the right", inherited 
> from Java. But it doesn't need it because D has unsigned types, which 
> can be used to effect unsigned shift. (Java, lacking unsigned types, had 
> no other way around but to define a new operator.)

It's there because in C/C++ one often winds up writing:

    (unsigned)x >> i;

to ensure that one gets an unsigned right shift. The problem is that the 
cast can have many other side effects if x is not of type int. For 
example, if x is a struct with an overloaded cast operator. Or if x is a 
long and you just lost half your value.

> Should we yank operator>>>?

No.



More information about the Digitalmars-d mailing list