[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Serialize closure by dump
- From: Patrick Donnelly <batrick@...>
- Date: Fri, 5 Nov 2010 04:20:02 -0400
2010/11/4 libla <libla@163.com>:
> I try to serialized closure used "string.dump", but I find that the
> upvalues were set nil when deserialize the closure.
> [..]
> Is there any solution?
Yes. You can use my serialization library [1]. Sergey is incorrect in
that it is not possible to serialize upvalues. You just can't
(de)serialize *shared* upvalues *correctly*. My library uses an old
shareupvalue patch [2] I shared a while ago which the Lua authors now
have implemented in the form of debug.upvalueid and debug.upvaluejoin
in Lua 5.2.
In any case, you can still serialize most functions with upvalues correctly.
[1] http://www.batbytes.com/serialize.lua
[2] http://lua-users.org/lists/lua-l/2008-02/msg01173.html
--
- Patrick Donnelly