lua-users home
lua-l archive

Re: Serialize closure by dump

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


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

AltStyle によって変換されたページ (->オリジナル) /