lua-users home
lua-l archive

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


On 23/03/2014 07:09, Jeremy Ong wrote:
> Many binary protocols are more easily expressible with raw binary than
> hex. This is because, to save space, single bits are often used to
> represent something (possibly a continuation bit), thus allowing a
> tighter packing.
> 
Yep, that was, more or less, the use case I had in mind.

also @steve:

with the introduction of bitwise ops and 64bit integers Lua becomes more
attractive for bit fiddling. Packing binariy numbers in hex is useful
IMHO only when the individual bits have no specific meaning.

When you come to representing status registers of devices, complex
protocols and so on, being able to express them explicitly enhances
readability and documentation.

As you point out, you can exploit Lua syntax and function calls for that
(and also for the digit separator I proposed), but having that
feature at parsing or lexing level probably adds very few C lines to Lua
code and allows using that feature with less fuss in embedded devices or
in computationally-constrained contexts.

Of course YMMV.

Cheers.

-- Lorenzo


-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments