about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-10-24 14:20:37 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-10-24 14:20:37 -0700
commite35454c9a8e01637cc06f07586e58e470025f082 (patch)
treefa518cd83c4146eb8247752cb8f87576a35a8d3a
parentd8fcd648d79552e42ceea94a567743317ac08251 (diff)
downloadteliva-e35454c9a8e01637cc06f07586e58e470025f082.tar.gz
I don't yet understand the stack
-rw-r--r--src/lua.c3
-rw-r--r--src/notes6
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