[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature proposal: \x## notation in strings
- From: Ico <lua@...>
- Date: Mon, 9 Mar 2009 23:18:56 +0100
* On 2009-03-09 Alexander Gladysh <agladysh@gmail.com> 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.
Ico
(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!)
--
:wq
^X^Cy^K^X^C^C^C^C