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 tobias@justdreams.de once stated:
> 
> I'm designing a library which has a Buffer module that allows to  
> contain binary data.  Think of it as a string just with less features  
> :-P 

  There was a heated discussion about this back in 2014:

	http://lua-users.org/lists/lua-l/2014-08/msg00819.html

I wrote test code (it's still available) to test that a buffer userdata
would be faster than Lua immutable strings.  Immutable strings were faster,
but like I said, I could have done something wrong.

> I don't think there is a 'right' answer, but to all those people who  
> work with this kind of stuff, what would feel more natural to you?
> Also, does Segment( offset, length ) makes more sense than Segment(  
> length, offset ) ?

  When I work with this kind of data, I either pass it to C for parsing (Lua
5.1), use string.unpack() (Lua 5.3) or LPeg, depending upon the type of
data.  For building data, it's either string concatenation, C (binary
packets under Lua 5.1) or string.pack() (Lua 5.3).

  -spc (Coroutines never did get back to me about my code ... )