lua-users home
lua-l archive

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


Hi,

The LRM (p22) says the relevant pseudo-code for __index is:

...
if type(h) == "function" then
 return h(table, key)
else ...

However this code:

print(setmetatable({}, { __index = function() return "one", "two" end })[1])

prints "one" with both Lua and LuaJIT.

This has been discussed before in http://lua-users.org/lists/lua-l/2007-07/msg00177.html , and it looks like the conclusion was that it's too hard to change __index to return more than one value.  Since I imagine the LRM is getting edited for 5.2, any chance the pseudo-code could be updated something like this, or an explanation added?

if type(h) == "function" then
 return (h(table, key))
else ...


Cheers,
Geoff