lua-users home
lua-l archive

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


That is very interesting. I modified Lua in the way you describe, and I get these
results.
Is these the same with what you are proposing?

Exactly as. I don't know if you tested the scenario of :

-- Index Class No Function Calls
local proxy = setmetatable({greeting = "hi"}, {__index = function(tab) return rawget
(tab, "greeting") end})
local test = setmetatable({ }, {__index = proxy})
print(test.greeting)

-- Lua: hi
-- Modified Lua: hi

I did test this. It is example 3 in my previous post. I don't get the results show above, but instead

-- Lua: hi
-- Modified Lua: nil

In the modified Lua, since the index function in proxy is passed the test table, how does it obtain the "hi" value for greeting which is in the proxy table?