On Mon, Aug 25, 2014 at 8:47 AM, Philipp Janda <siffiejoe@gmx.net> wrote:
You will probably have to write your own buffer userdata for that. I don't
think such a userdata is useful enough for most people that it should be
included in Lua's standard library (compared to a `FILE*` which is the only
userdata in Lua right now). If you really need pattern matching etc. in your
socket buffers, I suggest you start with a modified copy of `lstrlib.c`
(it's MIT after all). But even if you implement all string functions for
your buffer userdata, you won't be able to replace the immutable string type
in Lua because (immutable) strings are hashed by contents and (mutable)
userdata are hashed by identity/address. It would get awkward fast if you
modified the contents of a table key ...
I can make my own version of the string library that would largely be
duplicated code, as I'm just trying to get those functions to operate
on userdata. I was hoping an interface/function-or-3 would be made
upstream to allow one to trick functions that take strings to accept
userdata.