LUA_PUSHCCLOSURE(3) | Library Functions Manual | LUA_PUSHCCLOSURE(3) |
lua_pushcclosure
—
pushes a new C closure onto the stack, function indicator
[-n, +1, m]
#include
<lua.h>
void
lua_pushcclosure
(lua_State
*L, lua_CFunction
fn, int n);
lua_pushcclosure
()
pushes a new C closure onto the stack.
When a C function is created, it is
possible to associate some values with it, thus creating a C closure; these
values are then accessible to the function whenever it is called. To
associate values with a C function, first these values should be pushed onto
the stack (when there are multiple values, the first value is pushed first).
Then
lua_pushcclosure
()
is called to create and push the C function onto the stack, with the
argument n telling how many values should be
associated with the function. lua_pushcclosure
()
also pops these values from the stack.
The maximum value for n is 255.
Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, Lua 5.1 Reference Manual.
The lua_pushcclosure
() manual page is
based on Lua Reference Manual 5.1 and was created by Sergey Bronnikov.
July 18, 2022 | Debian |