lua-users home
lua-l archive

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


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.  I know of no simple way to do this.  (tricking
lua_isstring() and friends)

Repeating what I have said earlier: I realize this would be a security
risk, and I hope that if something is possible it could be controlled
through a function or boolean switch within the debug library.