[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Lua pattern for a main chunk to leave a function on the stack
- From: Benjamin Riggs <riggs@...>
- Date: Sun, 14 Nov 2021 03:08:44 -0600
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?