Thanks for the feedback! > [BTW: Why didn't you use the API names from Lua 5.2?] I didn't realize they were added to Lua 5.2, no reason I can't use those names. > But ... why is all of that necessary? Why serialize two functions > that obviously had to have a common parent? Why not serialize the > parent instead? That would avoid all of the logic. I want to be able to handle cases where it is not clear what the parent function was. For instance: local makeobject() local i return { get = function() return i end, set = function(a) i = a end } end local obj = makeobject() serialize(obj) --uses upvalueid internally Zach On Thu, Jun 14, 2012 at 3:20 AM, Mike Pall <mike-1206@xxxxxxxxxx> wrote: > Zach Devito wrote: >> Can anyone comment on whether this code should work in general, and on >> any issues I might be missing? > > Well, it doesn't error out on non-positive upvalue indices. And, > yes, it's really absolutely necessary that those functions haven't > been run (esp. not JIT-compiled) -- which is hard to verify. Umm, > and it might break on future changes that improve static upvalue > analysis. > > [BTW: Why didn't you use the API names from Lua 5.2?] > > But ... why is all of that necessary? Why serialize two functions > that obviously had to have a common parent? Why not serialize the > parent instead? That would avoid all of the logic. > > --Mike >