When thinking about loading / saving mechanics for a game using Lua coroutines, a rather interesting question arose - can you dump the current state of Lua to a file completely? In addition to the obvious solutions for dumping the environment, two notable problems arose - dumping functions (which, in my opinion, are simpler), and dumping coroutines.
The latter made me wonder if it is even possible to reset the current coroutine to resume the call later. The uses for this would be quite wide - in the end, it would allow to serialize running tasks and transfer them in the Erlang style.
Therefore, the question is - is this possible?
I am not looking for a (possibly obvious) answer โnoโ, because, perhaps, it is possible to some extent of the required work (ergo, in the worst case, you can try to hack the compiler). I wonder how much it will be ...
source
share