I don't yet understand the stack

This commit is contained in:
Kartik K. Agaram 2021-10-24 14:20:37 -07:00
parent d8fcd648d7
commit e35454c9a8
2 changed files with 4 additions and 5 deletions

View File

@ -378,6 +378,9 @@ int main (int argc, char **argv) {
}
initscr();
echo();
lua_pushinteger(L, 42);
lua_setfield(L, -1, "answer");
//? lua_setglobal(L, "answer");
s.argc = argc;
s.argv = argv;
status = lua_cpcall(L, &pmain, &s);

View File

@ -9,9 +9,5 @@ lua_State:
GCObject* next
byte tt # type == THREAD
initializing a lua_State (lua_newstate)
allocate space (including for globals)
next = NULL
stack = NULL
Lua's stack vs globals: https://lucasklassmann.com/blog/2019-02-02-how-to-embeddeding-lua-in-c/#exposing-a-simple-variable
More info on the stack: https://www.lua.org/pil/24.2.html