lua-users home
lua-l archive

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


>>I have mixed feelings about Lua not including such a library
>>natively.  On the one hand, bit manipulation is such a common
>>operation that it should be part of Lua.  On the other, part of the
>>appeal of Lua is that the language doesn't have a lot of fluff.

Brian Hook
> Sorry, can't pass up some snitty comments =)
> Bit manipulation would seem to be, honestly, to be the complete
> counter-definition of "fluff".  Integers and bits, these are the
> fundamental building blocks of, um, everything.

Bits make up everything and are fundamental, while hash-keyed tables are far
from machine level. Yet Lua rates Tables as fundamental building blocks and
not bits. Why? Because it is a 'high level' language (ie, it adds a level of
abstraction).

How fundamental are Tables? EVERY Lua program uses them... you won't be able
to go more than a few lines before you see one being accessed.

What about Bits? Most programs have no need for them so they can hardly be
considered as 'fundamental' from a Lua point of view. Why clutter up the
memory with a feature perhaps 1 in 1000 programs might use? If you are doing
something that relates to the low level machine then add some C functions to
handle it.

> I kid, I kid.  Well, I don't kid really, but I jest.  I respect Lua
> and the team, this is just something that recently bit me in the ass
> trying to port some C code to Lua, and the C code is rather
> performance intensive and requires lots of bit manipulation.  Enough
> that this is a bottleneck.
>
> Unfortunately, it's not structured such that I can just isolate it as
> a native function either.
>
> I'll survive, I'm sure =)

Despite what I said above it might be nice if Lua added a few more
(metatable trapable) infix & prefix function miscellaneous symbols for
people to use (eg, "|", "&", "!"), even if they don't have any direct Lua
meaning. Otoh, I guess it's best to save symbols for when they might be
needed!

*cheers*
Peter Hill.