lua-users home
lua-l archive

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

* On 2009-03-09 Alexander Gladysh <> wrote  :

> > I'm using Lua a lot for embedded software, which tends to involve quite
> > a bit of working with low-level protocols, bits and binary data. One of
> > the things I'd personally like to see added in Lua to make my life a bit
> > easier is the C-like notation for 'binary' data in strings using
> > hexidecimal escape codes like \xNN.
> Probably this is a silly question, but is decimal notation not
> acceptable? I guess hexadecimals may be a bit more convenient in some
> cases, but they should be more or less equivalent.

Decimal is perfectly acceptable indeed, although hex would be a nice
addition, and I see no obvious reason why this could not be added to Lua
with minimal effort. I could be missing something here, of course.

In the embedded field hexadecimal notation is very common, especially in
things like protocols or hardware registers where every bit can have a
separate meaning. Converting mentally between bits and hex is quite
trivial once you get the hang of it, but converting between bits and
decimal is much harder to do.


(Speaking of bits: I also like to make my vote heard for the addition of
bit-handling functions, or even better, operators to the lua core. I'd
kill for some high-performance bit clear, set, shift, and, or, and
similar operations!)