lua-users home
lua-l archive

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


On Tue, Jan 31, 2012 at 12:54 AM, David Manura <dm.lua@math2.org> wrote:
>
> On Mon, Jan 30, 2012 at 11:12 PM, Miles Bader <miles@gnu.org> wrote:
> > [bit libraries] to remain
> > portable by just writing to the common subset of (and as they have
> > different names, it's probably not to hard to do a bit of emulation).
>
> The pure Lua bit.numberlua library [1] provides compatibility
> interfaces for both 'bit' and 'bit32', and a couple of my modules
> (e.g. digest.crc32lua and compress.deflatelua) natively support all
> three bit libraries, doing things like
>
>  local bit, name = requireany('bit', 'bit32', 'bit.numberlua')
>  -- sometimes with conditionals on module `name`
>
> [1] https://github.com/davidm/lua-bit-numberlua
>

Ah, this does look handy.

At a quick glance, there's a part in each of the bit32_* functions
that looks a little suspicious, e.g. in bit32_bxor:

    if c then
      z = bxor(z, c, ...)
    end

Inside the if, it ought to recurse on bit32_bxor instead of calling
the two-argument bxor, no? And likewise for the others.