lua-users home
lua-l archive

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

On 10 jun 2009, at 11:15, Olivier Hamel wrote:

Hans van der Meer wrote:
As I did a bitmap implementation, I hereby add its html-docs of this for what it is worth in the discussion. Interested parties can find the code here (use it with due credit): <>

My first thought when I read 'bitmaps' was Win32 bitmaps, after which I read this and it seems to be some sort of massive array of bits which can be manipulated?

Yes, it is an array of bits, packed as tight as can be. Bits in the array can be set, queried and iterated on. The testfile in the package does a prime number sieve of Eratosthenes as an example, showing that very many boolean flags can be manipulated comfortably.

Oh wait, this is a wrapping of a number handled as an object /w metamethods, correct?

Indeed, metamethods may be used for combining bitmaps with AND, OR, XOR.

If it is then this is a new take on the problem I hadn't considered at all! Nice to see a new take on the problem, but I'd be annoyed at using such an interface when I want to just do i = i << 1 and then use i for some other calculation.

Roberto said they (inner Lua dev group) weren't happy with any known implementation of bitwise operators, it would be helpful to know what they are not pleased with so we may propose alternate solutions/implementations.

The module cannot do arithmetic operations(like i<<1 or i>>1 for doing powers of two). It was not designed as such and I agree with the quote of Roberto in that one should not lightly tamper with arithmetics.

Hans van der Meer