lua-users home
lua-l archive

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


On Mon, 24 May 2010 16:53:32 -0700, Jonathan Castello <twisolar@gmail.com> wrote:


I wrote your algorithm into a usable Lua function to try it out. I had
to add a check for nonexistent metatables, but it does work.


From the manual:

"The code shown here in Lua is only illustrative; the real behavior is hard coded in the interpreter and it is much more efficient than this simulation. All functions used in these descriptions (rawget, tonumber, etc.) are described in §5.1. In particular, to retrieve the metamethod of a given object, we use the expression

     metatable(obj)[event]

This should be read as

     rawget(getmetatable(obj) or {}, event)"