lua-users home
lua-l archive

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

* On Tue Jul 09 20:02:48 +0200 2013, Jerome Vuarand wrote:
> > We are considering adding bitwise operations to Lua. After all, the main
> > reason Lua did not have them was that they were awkward as primitive
> > operations over floating-point numbers. With integer numbers, this
> > problem is gone.
> In other words it feels a little too low level (like the goto
> feature), and the overlap with C, which Lua complements so well, may
> compromise some of the uniqueness of Lua.

It probably very much depends on the type of application and programmer.

People who regularly use bit operation probably do so in a language
where native operators are available (i.e. C), and chances are they are
familiar with the various idioms, for example

  val = val & ~mask

for clearing bits in a word. Doing this with bit32 does not result in
code that is more readable, IMHO:

  val =, bit32.bnot(mask))

For a user not familiar with bit operations both probably look as
confusing, but the first at least feels more natural to those who *are*
regularly using binary operators in other languages.

As for me: I'm using Lua a lot for pretty low level embedded targets,
and having bitops would make my code cleaner and my life a bit easier.