lua-users home
lua-l archive

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


On 05/05/2014 10:13 PM, Coroutines wrote:
If strings did not have a metatable then [] could
be sugar (not __index) for looking up the byte at that index (a sort
of fast-tracked C call).

I don't see a problem here. AFAIK the standard string metatable does not define any number fields. That means that you could easily patch the VM to index the string when you call string[Number] if the index is not a number, Lua would fall back to the metatable, as usual.

It would only be a problem for user defined metatables for string that define numerical index, with a different meaning.
--
Thomas