[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua pattern for a main chunk to leave a function on the stack
- From: Flyer31 Test <flyer31@...>
- Date: Sun, 14 Nov 2021 12:09:52 +0100
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
> 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?
> Benjamin Riggs