lua-users home
lua-l archive

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


On 2 November 2011 20:24, liam mail <liam.list@googlemail.com> wrote:
> 2011/11/2 Ing. Jan Supuka SBM <sbmintegral@sbmintegral.sk>:
>> In newest LUA 5.2 beta is implemented UNSIGNED INTEGER type and library
>> bit32 for bitwise operations.
>> BEAUTIFULL !
>>
>> But I don't like write
>>    a = bit32.bor(bit32.band(5,2345),bit32.band(23,7))
>> instead of
>>    a = 5&2345|23&7
>> that's why I rework source codes ( lua-5.2.0-beta.tar.gz [NEW]
>> 2011-07-08
>>                                http://www.lua.org/work/lua-5.2.0-beta.tar.gz
>> )
>> to use "native" operators (based on
>> http://www.wra1th.plus.com/lua/risclua.html source code) :
>>    band &
>>    bor     |
>>    bxor    ^^
>>    lshift <<
>>    rshift >>
>>    bnot    ~
>> and my own logical operators:
>>    and &&
>>    or      ||
>>    not     !
>>
>> All source code changes are dependent on (luaconfig.h)
>> #define GCW_BIT
>> /*
>> GCW_BIT: Use bit library.
>> This extends virtual machine with bitwise operations
>> &,|, ^^, ~, <<, >> and provides corresponding events.
>> Warning! Makes code non-portable.
>> Affects c.lvm, c.lcode, c.lopcodes, c.ltm
>> c.llex, c.lparser, h.lcode, h.lopcodes
>> h.ltm, h.llex, h.luaconf.
>>
>> additionally NUM_logical operators ( return numerical (1,0), not boolean
>> values )
>> !,&&,||
>> */
>>
>> IMPORTANT:   in standart LUA is not possible use boolean (true,false) in
>> arithmetical operations,
>> but I need it.
>> On (lvm.c line:375) is it possible (unremark) allow using booleans only for
>> new operators.
>> ------------------------------
>> Need tests, if all is correct.
>> ------------------------------
>>
>> SOURCE:
>> http://sourceforge.net/projects/lualubit/files/
>> BASIC TEST ... approximately 5x faster native versus bit32.bxxx operators,
>>  more readable LUA source
>>
>>
>>
>>
>>
>
> Thanks it looks interesting although on first try to compile I get an
> error about luaopen_mathx being undefined, is this a private maths
> library?* So I have not yet run the speed tests but I would recommend
> some changes in both Rio Lua usage and your own.
> Such as:
> Don't use io operations inside a profile test
> Use locals instead of globals
> Be nice to Rio Lua and cache bit32.band et al to locals ie local band
> = bit32.band
>
> * also a warning is generated for lvm.c:380 suggest parentheses around
> && within ||
>
> Liam
>

Oh, I forgot to say did you have a Lua Uppercase Accident :)
Lua != LUA

Liam