lua-users home
lua-l archive

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


On 2023-07-18 09:26, Marcus Mason wrote:
Suppose you have a coroutine which is suspended at some point in its execution. Would it be possible via a C API trick or extension of the c API to duplicate it so that I have two independently runnable coroutines in the same state? Said coroutines are always pure.

Currently, no. (I vaguely recall that a long time ago someone made an experimental patch. Might have been targeting LuaJIT, not sure…) I also tried poking at things at some point and it should be doable, but don't understand the internals of Lua well enough to get it to run.

Would be really nice to have for backtracking search (put it in a coroutine and at branch points yield/clone/resume) and some other "variations on the same thing" style problems.

-- nobody