lua-users home
lua-l archive

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


It was thus said that the Great Andrew Starks once stated:
> 
> Specifically, the debug.Csize, integer and float packing functions; there
> usage is clear, but I'd be interested to know about the thinking around
> including these sorts of tools, absent a lua-side buffer type. Most of
> these are in the string library. The cost/benefit must have tilted toward
> strings. It'd be interesting to know more about that genral topic, even if
> that specific issue turns out to be "not interesting."

  I'm not sure about debug.Csize(), but string.dumpint(),
string.dumpfloat(), string.undumpint() and string.undumpfloat() are useful. 
I just recently added htons(), htonl(), ntohs() and ntohl() to my networking
library [1][2].  It would also be useful for parsing zip files [3] and other
binary structured files.

  -spc

[1]	https://github.com/spc476/lua-conmanorg/blob/master/src/net.c

[2]	hton*() takes a number and returns a string, whereas ntoh*() takes a
	string and returns a number.  I'm using it to parse binary protocols
	at work.  I was able to replace almost 2,800 lines of C code with
	600 lines of Lua.

[3]	https://github.com/spc476/lua-conmanorg/tree/master/lua/zip