lua-users home
lua-l archive

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


> Yes, this is what's expected -- I just disagree with the code
> duplication a lot :>

So code duplication is bad? Never look at code duplication? You aren't making one of these generalisations here you are hating so much?


On Mon, Aug 25, 2014 at 6:35 PM, Coroutines <coroutines@gmail.com> wrote:
On Mon, Aug 25, 2014 at 9:22 AM, Philipp Janda <siffiejoe@gmx.net> wrote:

> The string library doesn't make sense for generic userdata, it only makes
> sense for character arrays a.k.a buffers. That's why I suggested you write a
> buffer userdata type. And please don't try to replace the string library
> with your own version. Just take `lstrlib.c`, replace `luaL_checkstring`
> with `luaL_checkudata`, and register those functions as methods of your
> buffer userdata. Yes, you duplicate a lot of code, but you stay backwards
> compatible with current Lua, and you stay type-safe.

Yes, this is what's expected -- I just disagree with the code
duplication a lot :>

> But it would be a shame if your socket library only worked in debug mode,
> wouldn't it?

If I care this much about performance and not stressing allocations, I
think I'd be okay with requiring the debug library be present -- that
said, I haven't worked in a lua env where it hasn't been available.
I've made sandboxes where I've personally removed it, though.  I don't
feel like it would be a very distressing dependency.. but you have a
point.