lua-users home
lua-l archive

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



On 08/12/14 02:15 PM, Dirk Laurie wrote:
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?

local _ENV = {string = {}}
print(_ENV.string == getmetatable"".__index) --> false

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.