Well not sure what you mean. I'm no expert on lua, but do find it interesting how it remember local variables in functions.
local name = 'a name'
test2 = function()
Some how name is remembered. test2 could also change the name to different values. I would think that once test() is called all its data is pushed off the stack after its returned. Which would mean the variable name would be gone, but it isn't.
A lot of my options code works this way. I have a function that creates options , but also has variables in that function to keep track of stuff.
Thats called an upvalue. If a local variable is referenced in a new closure, it will live as long as the closure exists. Its the concept of lexical scoping, which in conjunction with first-class functions, makes Lua so powerful. Details at