I'm new to Lua and using it to run user-supplied business logic on an embedded system. The API I would like is for chunks to be loaded and run with each chunk leaving a function (with a closure) on the stack. This returned function will then be called periodically and will update state values. I'm trying to avoid requiring user code to use a designated name and trying to minimize the boilerplate of registering or assigning the function.
Is there an elegant pattern that enables what I want?
Thanks
--