lua-users home
lua-l archive

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


2014-04-12 12:15 GMT+02:00 duz <duz@sol-3.de>:
> On 12.04.2014 12:08, Dirk Laurie wrote:
>
>> Among the things I hit my head on were:
>>
>> 1. The notation z[x,y] does not translate to __index(z,x,y).
>
>
> And did you complain, why it doesn't?
> Were you satisfied with the answer?

I did not complain, but read the manual and PiL, and found the answer.
It was that __index should be a drop-in replacement for rawget.

So that, inter alia, the way in which it is used in the API remains valid.

---

int lua_gettable (lua_State *L, int index);                     [-1,+1,e]

Pushes onto the stack the value t[k], where t is the value at the given
index and k is the value at the top of the stack.
...
As in Lua, this function may trigger a metamethod for the "index"
event (see §2.4).

Returns the type of the pushed value.
---

I was satisfied with that answer.