[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Serialization of Function Values
- From: Carlos Augusto Teixeira Mendes <cmendes@...>
- Date: Tue, 03 Apr 2001 10:05:03 -0300
>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".
>--lhf
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
end
a = 100
print(f())
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.
[]s,
Carlos Augusto.