lua-users home
lua-l archive

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



On Apr 19, 2014 3:08 PM, "Hisham" <h@hisham.hm> wrote:

> On 19 April 2014 14:00, Jay Carlson <nop@nop.com> wrote:

> > If I had one wish for utf8.match, it would be for "." to either match
> > complete utf8 characters or fail.

> I didn't venture into suggesting Lua interfaces on this subject yet,
> but I think a utf8.match that does UTF-8 pattern handling by default
> would be a great place to do this, Lua-API-wise

Yeah.

> no compatibility issues; no global state;

I anticipate fights over what getmetatable("") returns. :-(  I don't see any way out of that hole.

It may be a good idea to have a well-known second name for string.*, like bytes.*, for code which wants to make very clear it knows it is working on bytes and does not wish anybody to monkey-patch string.* out from under it.

It's possible to lexically scope the choice of ".." operator; modules could say "I want C-style strings" or "I want error() if the result of concatenation is not in utf8." This can't be done with the string metatable, at least not directly.