lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, Jan 14, 2010 at 6:13 PM, Miles Bader wrote:
> I agree.  I think people almost always have a certain shift direction in
> mind, and it's much clearer to explicitly reflect this in the code.
> Use of negation to indicate this seems an obfuscation.

Merging lshift and rshift into one operator might be analogous to
merging addition and subtraction, multiplication and division, sin and
cos, etc.  We could, but we don't.

I don't know that "left" and "right" are the best terms, as it
arbitrarily labels the MSB and LSB.  When the shifts are labeled "+"
and "-", they operate in the same direction as increment and
decrement.  "Left" and "right" are conventional though.

The code bit.bshift(x, n) does convey less information than
bit.lshift(x, n).  Say if lua2c [1] translated the former to C, even
if it knew that bit.bshift was not redefined, I couldn't simply
replace it with a plain "<<", in the general case.  Is it that common
to write bit.bshift(x, n) where the signedness of n is not invariant
at compile time?