lua-users home
lua-l archive

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


On Thu, Nov 22, 2012 at 8:39 PM, liam mail <liam.list@googlemail.com> wrote:
> On 21 November 2012 21:36, Wolfgang Pupp <wolfgang.pupp@gmail.com> wrote:
>> Finally, making the bit* library work for such int64 types would be very nice.
>> I'm against bitwise operators because there are too many of them- too
>> hard to remember precedence rules for all of them. There are also some
>> things that *belong* into a bit library IMHO but don't have suitable
>> operators (popcnt would be very nice, e.g.), so a bit* library is
>> needed, anyway.
>
> Can I ask if you have written any Lua code which uses prefix functions
> for bitwise operations and if so do you really find the code easier to
> understand compared to code which uses operators?
>
> Personally I wish Hitchcock's birds would descend and pluck out my
> eyes rather than look at Lua bit function code.
>
> -- Liam
>

I once hacked up some metatable magic to allow writing pseudo-infix
operators like:

x = ((4) '<<' (3)) '|' (y)

It's ugly and inefficient, but it works! Probably biggest drawback is
not only the operators need to be quoted (since they're strings), but
the parameters need to be in parentheses (since they're either being
called or being function arguments), so it becomes bracket hell
quickly...

Really love to have real bit operators in Lua.

-- 
Sent from my Game Boy.