lua-users home
lua-l archive

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


On Mar 21, 2014 4:45 PM, "Luiz Henrique de Figueiredo" <lhf@tecgraf.puc-rio.br> wrote:

> Lua 5.3.0 (work2) is now available for testing at
>         http://www.lua.org/work/lua-5.3.0-work2.tar.gz

string.format uses a little language for constructing strings out of numbers and other strings, primarily in variable-length decimal encoding. I think a very similar language could be designed for constructing strings out of numbers and other strings in the domain of fixed-size binary encoding.

Aside from symmetry, my motivation is premature optimization. string.pack written in Lua would have the same problems as string.format written in Lua: as formatting is executed, short strings will be created, pushed on a Lua-side concat table, then turned into garbage. Easier and faster to do this at the C level where string building is cheaper.

Jay