LUAL_REF(3) Library Functions Manual LUAL_REF(3)

luaL_refcreates and returns a reference for the object at the top of the stack and pops the object, function indicator [-1, +0, m]

#include <lauxlib.h>

int
luaL_ref(lua_State *L, int t);

() creates and returns a , in the table at index t, for the object at the top of the stack (and pops the object).

A reference is a unique integer key. As long as you do not manually add integer keys into table t, luaL_ref ensures the uniqueness of the key it returns. You can retrieve an object referred by reference r by calling . Function luaL_unref(3) frees a reference and its associated object.

If the object at the top of the stack is nil, luaL_ref returns the constant LUA_REFNIL. The constant LUA_NOREF is guaranteed to be different from any reference returned by luaL_ref.

luaL_unref(3)

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

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

July 21, 2022 Debian