lua-users home
lua-l archive

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


On Tue, 24 Mar 2009 11:43:58 -0300
Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:

> > i made serialization function that can write out table with
> > cross-references and (wow!) functions with (wow!) upvalues.
> 
> I could not make it run. Does it support *shared* upvalues as in the
> program below? I mean, does it serialize f,g, and h correctly?
> 
> do
> 	local x=0
> 	function f() x=x+1 return end
> 	function g() x=x-1 return end
> end
> 
> function h()
> 	assert(f(g()) == g(f()))
> end
if you put the function in table (like this):
local t = {
  fn = h;
};
it should write out the thing correctly.

there can be issues with code (it taken from the live and complex
program), but nothing an average Lua programmer can't fix. i really can
miss something, but not anything crucial.

i'd like to hear any bugreports though. if it works, somebody can put
it in the wiki, i think (i'm toooooo lazy to do it myself for now, and
i'm not sure it works ok, so please, test it).