Can you dump a running Lua coroutine to a file for a later resume?

While thinking of load/save mechanics for a game using Lua coroutines a quite interesting question has arisen -- can you dump a running Lua state to file completely? Apart from the obvious solutions of dumping the environment two notable problems have arisen -- dumping functions (which I think is easier), and dumping coroutines.

The latter made me wonder, whether it is possible at all to dump a running coroutine for a later resume call. The uses for that would be quite wide -- in the long run it would allow serialization of running tasks and passing them around Erlang style.

Hence the question -- is it possible?

I'm not searching for the (maybe obvious) "no" answer, for it probably is possible at some degree of work required (ergo in the worst case one could try to hack the compiler). I'm interested in how hard it would be...

5
задан Kornel Kisielewicz 10 March 2011 в 00:40
поделиться