From e35454c9a8e01637cc06f07586e58e470025f082 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 24 Oct 2021 14:20:37 -0700 Subject: I don't yet understand the stack --- src/lua.c | 3 +++ src/notes | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lua.c b/src/lua.c index 88cd29b..e40b61c 100644 --- a/src/lua.c +++ b/src/lua.c @@ -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); diff --git a/src/notes b/src/notes index 6f609ff..3a87b2a 100644 --- a/src/notes +++ b/src/notes @@ -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 -- cgit 1.4.1-2-gfad0