lua-users home
lua-l archive

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


I agree with Mike's post generally, and urge the Lua devs to consider it.

Mike Pall <mikelu-1001@mike.de> writes:
> In all the years I've been writing C and assembler I've never had a
> need to mix left and right shifts controlled by the same variable
> holding a signed shift count.

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.

I've programmed in languages which use the
"one-shift-operator-negative-reverses" style, and indeed, have found the
use of negation to indicate right shifts simply makes the code more
confusing.

Also important to many people is that since the
one-shift-operator-negative-reverses style is farther from underlying C
and machine operations, it's for harder for luajit or whater to optimize
-- and such low-level bit frobbing code is probably exactly the sort of
thing people _expect_ to be optimized well...!

Arithmetic right-shift is also very important.

-Miles

-- 
"1971 pickup truck; will trade for guns"