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 <> wrote:
> On Mon, Jan 30, 2012 at 11:12 PM, Miles Bader <> 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]

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, ...)

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