lua-users home
lua-l archive

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


Lisa Parratt wrote:
David Jones wrote:
Treating an int as 32 bits indexed from 0-31 is just an optimised representation of a table. Let's not elevate that optimisation to the status of discrete mathematics. Personally I find that about half the time when I want to use bitfields I end up overflowing the 32-bit ceiling anyway (in C this is), so you have to use non-basic types anyway.

Please be explaining to me how you can do discrete mathematics in stock Lua without such operators, without requiring one of those academic theoretical computers with infinite CPU power and memory? Either you're being a pedant for the sake of it, or so intensely impractical I question why I bother.

I'm a practical pedant.

You know how to do set operations in Lua, just use tables. If I want things to go fast, I'll use C. Why would I constrain myself to using stock Lua? The whole point of Lua is that it's extensible, if I'm using Lua I _expect_ to extend it, so why shouldn't I add a bit-table library. If I want a more powerful language out of the box then I'll use python.

Since I spent practically the whole of last year inside an 8-bit micro with 3.25 KiB of RAM I find your comments about infinite CPU power and memory amusing. We couldn't run Lua on it, but that didn't stop me wanting to and fantasizing about it.

You ask too much. Can Lua be small, portable, fast, extensible, easy to configure, and have benevolent and understanding caretakers? Yes. Can it do all of these things and let you write: "(cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))"? Yes, of course. Without you putting in a little extra work? No.

Personally I can live without the operator syntax for bitwise operators, as I have to in C a lot of the time anyway, but it would be _nice_ to have. Not wonderful, nor required, just nice. Is it worth hacking around with the language just to add a nice feature? I don't know.

Why the stock Lua requirement?

drj