[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua 5.2.0 (alpha-rc2) now available
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Fri, 19 Nov 2010 06:24:22 +0100
David Manura wrote:
On Thu, Nov 18, 2010 at 11:23 PM, Miles Bader <email@example.com> wrote:
Nick Gammon <firstname.lastname@example.org> writes:
What is the motivation for the ALL CAPS function names in the bit library?
My guess it is to avoid the use of the reserved words "and" and "or".
However it does look UGLY.
Yeah; "band", "bor" etc are hardly _pretty_, but they're at least
somewhat familiar and normal-looking. AND, OR, etc, just stand out
absurdly in code, and scream for attention.
With code having lots of bitops, I'd probably do things like
local OR = bit.bor or bit32.OR -- prefer JIT-optimized ops
local AND = bit.band or bit32.AND
local NOT = bit.bnot or bit32.NOT
if not t or NOT(OR(x,y)) == 1 and AND(z,w) == 0 then ... end
I wonder why no one has suggested bit32.And, bit32.Or ... etc.
Does that look less ugly? At least it doesn't call to mind constants (to
me at least).
But I must admit that, after all, you could always do that as
local And = bit32.AND