lua-users home
lua-l archive

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


> if _VERSION >= 'Lua 5.2' then
>  function atexit(fn)
>    setmetatable({}, { __gc = fn })
>  end
> else
>  function atexit(fn)
>    getmetatable(newproxy(true)).__gc = fn
>  end

Note that this is not a good atexit() function — it would be called at
the next full GC cycle.

You have to store the object somewhere.

Alexander.