lua-users home
lua-l archive

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



You might want to study the source code of Lanes. It does copy closures stack-to-stack and that could most likely be modified to serialize them as well.

But even then, you won't be able to serialize userdata. I think even the "serialize yourself" feature would need to leave userdata out of the equation. And the rest can be done already. If you have any questions of the Lanes internals, pls. send mail to me directly.

-asko


ketmar kirjoitti 23.3.2009 kello 7:23:

On Mon, 23 Mar 2009 07:09:56 +0200
Asko Kauppi <askok@dnainternet.net> wrote:

I would recommend another (simpler) kind of mechanism:

- have all of your application state in a separate table (or in the
_G)
- store that table when exiting
- read that table when re-launching, and if it already contains
stuff, rebuild your application's visual appearance accordingly
- in regular exit (truly quitting the software) erase the state
table so the next launch will be "virgin"
it may be good for GUI apps, but it's inappropriate, for example, in
complex rogue-like game. the power of Lua closures allows to write
simple callbacks as anonymous functions, and those will not be
serialized properly. so I must either drop the idea of using anonymous
functions, or write alot of additional code to serialize/deserialize
such things. the both ways are bad, 'cause turn simple things to
overcomplicated ones.

i wonder if Lua 6 can include some built-ins for easy
serialization/deserialization of the interpreter state (with
metamethods for userdatas). as Lua is good suited for game scripting,
it can be much friendlier to game developers (and not only for them
%-). just ask Lua: "serialize yourself with this chunk writing
function" and "deserialize yourself with this chunk reading function".

maybe something like Pluto, but tightly integrated with Lua and with
deep knowledge about internal interpreter structures.