lua-users home
lua-l archive

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


2014-05-01 9:21 GMT+02:00 David Demelier <demelier.david@gmail.com>:

> Some functions already return the type retrieved like lua_getuservalue,
> lua_getglobal. It would be nice to have the same behavior for lua_getfield.
> So one can easily do:
>
> if (lua_getfield(L, -2, "x") == LUA_TNUMBER)
>     x = lua_tointeger(L, -1);
> lua_pop(L, 1);

I think it already does so in lua-5.3.0-work2/src.

| LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k);

It's just the manual that lags behind.