yank '>>>'?

Don nospam at nospam.com
Sun Dec 6 11:41:15 PST 2009


dsimcha wrote:
> == Quote from bearophile (bearophileHUGS at lycos.com)'s article
>> Andrei Alexandrescu:
>>> Should we yank operator>>>?
>> We can change it purpose and add the other one:
>> <<< rotate left
>>>>> rotate right
>> Bye,
>> bearophile
> 
> This is a good idea, although rotate may be seldom enough used not to warrant its
> own (possibly overloadable) operator.  std.intrinsic might be a better place for
> rotate.  On the other hand, rotate is a single ASM instruction, at least on x86.
> In a close to the metal language, there needs to be a straightforward, efficient
> way to access it.

I think DMD should just do what gcc does: recognize that
(x << 32-n | x>>n)  is ror n
(x << n | x>> 32-n) is rol n

where x is int. Ugly, but doesn't require an intrinsic.




More information about the Digitalmars-d mailing list