|
Am 25.08.2014 um 12:08 schröbte Coroutines:
On Sun, Aug 24, 2014 at 7:25 PM, Sean Conner <sean@conman.org> wrote:The issue I have with this (and I can't speak for others) is that it doesn't really *buy* you anthying but pointless complexity.As I said in another post, looking at the contents of the io.stdout userdata was just an example. Ideally I'd want to present a buffer I recv() into from my socket library to Lua to be used like a string -- without becoming a string -- so I can avoid reallocating for that buffer over and over.
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 ...
Philipp