lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I assume you are C programmer and want to prepare the user environment in C?

In this case the typicaly quite easy way would be to use the
yield/resume functunality of C interface (see Roberto "Programming in
Lua" somewhere in the "very later chapters").

On Sun, Nov 14, 2021 at 10:09 AM Benjamin Riggs
<riggs@entropicengineering.com> wrote:
>
> 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
> --
> Benjamin Riggs