lua-users home
lua-l archive

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

>I've written a library to access the dump module in luac.
>It'll be released with 4.1.
>I think that the simplest way to do serialization is to write binary chunks
>because code for loading thses is already in place.
>But people have written serialization code that outputs Lua code.
>Search the lua-l archives for "pickle".

Please, correct me if I'am mistaken, but I belive that to properly
serialize a Lua function, two things are needed:

1 - Save the bytecode that defines the function semantic (which probably
can be done with Luiz to be released library).

2 - Save the function closure... Take the chunck below as an example:

a = 10
function f()
  return %a + 20
a = 100
The result printed by the above code is 30 and not 120 because the value of
%a was frozen at the moment of f's definition.  So, to properly serialize
f, one should be able to save it's closure too.

Carlos Augusto.