lua-users home
lua-l archive

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


2014-12-08 17:52 GMT+02:00 Thiago L. <fakedme@gmail.com>:
> Hi!
>
> Can we get a local _META, like _ENV but for metatables?
>
> s = "test"
> print(s:sub(1,2))
> do
> local _META = {string = {__index = {sub = function(s, i, j) return "nope"
> end}}}
> print(s:sub(1,2))
> end
> print(s:sub(1,2))
>
> would output:
>
> te
> nope
> te

Do you expect the relationship
   `_ENV.string == getmetatable"".__index`
to survive?