lua-users home
lua-l archive

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


Sorry Thomas, I should have been clearer.. the code I posted -will- crash lua under 
the existing system, but with the minor revision mentioned (but not described in 
detail) to the vm will produce the desired results.

On Tue Nov 27 17:19 , 'Thomas Lefort' sent:
>You can guess why. Next time test your code before you post ;-)

It seems correct when I think about it, because I cannot envision a scenario where 
you have:

Table1.__index = Table2; Table2.__index = function()

Yet would prefer Table2 do be passed to the function then Table1, should Table1 be 
the object being indexed. And in any case, being passed Table2 destroys any 
knowledge of Table1, but the other way around no information is lost as Table2 can 
be found through calls to getmetatable.

On Mon Nov 26 22:34, 'Bradley Smith' sent:
> 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

Which is the largest advantage in the alternative method - you can index a table's 
__index table without any function calls, but still use a function call on the 
table if necessary.

What are your thoughts?