lua-users home
lua-l archive

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


On 11 January 2016 at 19:42, Matthew Wild <mwild1@gmail.com> wrote:
> On 11 January 2016 at 21:06, Jonathan Goble <jcgoble3@gmail.com> wrote:
> I'm glad it is that way, or Lua would be Python. It doesn't mean your
> patch isn't useful, or clever. Personally almost every time I use %b,
> I wish it had a way to handle escaping.

Further, I think I used things like [["[^"]*"]] many times in my code
in situations where I should have used [[%B"\"]], had I had the
option. This would make it easier to write more robust code.

> But Lua simply isn't an all-features-included language.

Given that the net increase of the code size is 5 lines, and the
additional costs are two ints (memory) and one extra test in the loop
(execution), I think this feature should be at least given
consideration as something core-worthy. It is, after all, a clever,
useful and tiny patch. On the other hand, I don't think I'd pull an
extra dependency just to have %B (and I especially wouldn't if it
monkey-patched string.match). But then, I wouldn't pull an extra
dependency just to have string.rep() either, and that is in the core.

Speaking of extra cost concerns, I'm afraid any benchmark on this
would fall into the traps of microbenchmarks, but it would be nice to
know if the difference is even measurable. Performance analysis is
usually part of the process of proposing changes to Lua.

-- Hisham