LUA_GETUPVALUE(3) Library Functions Manual LUA_GETUPVALUE(3)

lua_getupvaluegets information about a closure's upvalue, function indicator [-0, + (0|1), -]

#include <lua.h>

const char *
lua_getupvalue(lua_State *L, int funcindex, int n);

() gets information about a closure's upvalue. (For Lua functions, upvalues are the external local variables that the function uses, and that are consequently included in its closure.) lua_getupvalue() gets the index n of an upvalue, pushes the upvalue's value onto the stack, and returns its name. funcindex points to the closure in the stack. (Upvalues have no particular order, as they are active through the whole function. So, they are numbered in an arbitrary order.)

Returns NULL (and pushes nothing) when the index is greater than the number of upvalues. For C functions, this function uses the empty string "" as a name for all upvalues.

Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, Lua 5.1 Reference Manual.

The lua_getupvalue() manual page is based on Lua Reference Manual 5.1 and was created by Sergey Bronnikov.

July 13, 2022 Debian