Lua C API Question
Quote:
|
That part is just saying that it is taking metatable.__index and setting the value for that table. The = metatable just means that it is using the pointer of L; lua_settable(L, -3) is the actual code, whereas metatable.__index is just saying what is happening. Notice the /* */ around it... Sorry if it doesn't make sense, but that is the absolute best I can do to explain it at a lower level without getting into the pointer structure for L and how it is being set.
Cheers, Josh |
I didn't know that anyone replied intil I tried looking for this thread again just in case. The list of unread threads on "My LQ" is so glitchy...
Quote:
Why would you want to set the metatable's __index field to the metatable itself? |
Code:
Example = {} |
It says that the __index metamethod (which can be a table instead of a function) is used when you try to get a table's member that doesn't exist. In that case, I would expect that setting the __index field of a table's metatable to the table's metatable would make it so that you can call methods using the "." operator instead of ":". But it doean't work that way. What am I missing here?
|
All times are GMT -5. The time now is 10:51 PM. |