lua-users home
lua-l archive

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


On 7 May 2015 at 16:53, Tom N Harris <whoopdedo@whoopdedo.org> wrote:
> On Wednesday, May 06, 2015 02:48:01 PM Enrico Colombini wrote:
>> My first try was a failure:
>>
>>    -- this will not load on Lua 5.2 because of the '|'
>>    local bor = bit32 and bit32.bor or function(a, b) return a | b end
>>
>> So I added a new module:
>
> Of course the other way to wrap a compatibility function with new syntax is
>
>     local bor = bit32 and bit32.bor
>                or load[[return function(a, b) return a | b end]]()
>
> But a module has its own obvious advantages.
>
> --
> tom <telliamed@whoopdedo.org>
>

This is sort of what I did in lua-http:
https://github.com/daurnimator/lua-http/blob/master/http/bit.lua