lua-users home
lua-l archive

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



This would certainly be an interesting addition to Lua itself.. Actually, I thought what you _already_ have accomplished to be close to impossible! :P

I can think of a few uses for such, including multithreading in a grid of computers, able to throw active threads around the grid. May I enquire as to your use/need of it?

As to modifying the files (active editing, while debugging?) the tough part would be mapping old line numbers into new ones. You could use a diff-like approach (they have the same problem, already solved). But you maybe need to limit to certain kinds of changes, a common solution I find impossible.

But...

How about just keeping it simple, and storing the _state_ of things that are running as a table, not as the Lua internal coroutines-and- all structure. What I mean is this (N770/800 maemo platform has a similar way for handling tasked-out processes):

- Program starts, reads initial state.* table
- It runs, in an event loop fashion, keeps all persistent state in state.* fields - If given an "exit yourself, saving state" message, it does exit (the process), state.* is persisted - Later opening will reload the state.* table, resuming the process with no apparent changes to the user

Things s.a. active GUI view, scrolling position etc. should in principle all be part of the active state. For dialogs, the open dialog with fields edited should be remembered (most maemo programs I believe just forget the dialog, which is not bad, no harm done).

This is the approach I plan to take, with the "Spyder" virtual PDA software, able to jump active processes from terminal to another, even across different operating system platforms.

-asko


Jonathan Shaw kirjoitti 10.1.2007 kello 13.20:

Hello!

I'm making extensive use of coroutines in the project that I'm working on, and I would like to be able to achieve two goals when it comes to serialisation: to be able to serialise the whole Lua state, including the coroutines and their call stacks and local variables, and to also be able to patch the scripts and have "old" saves work with the patched scripts.

I'm using Pluto (http://lua-users.org/wiki/PlutoLibrary) to serialise the Lua state and by necessity this saves out the function definitions as well as everything else (to ensure that when the coroutines are resumed they continue from the same place in the same function they were in when they were serialised). However, this means that it's then impossible to patch the scripts, because if you load a Lua state serialised in this way then all of the patched functions will be overwritten by the unpatched functions that were saved earlier. But if I tried to change Pluto so that it doesn't save out function definitions then it won't necessarily resume the coroutines from the correct places, as the patched functions will have different line numbering in them.

Is there a way around this, or am I trying to achieve the impossible here? Thanks in advance for any advice!

        Jonathan