lua-users home
lua-l archive

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


> If I don't care about that change in semantics, is the minimal change
> to Lua 5.1 to move the cleartable call above the marktmu call? I've
> got my two-stage, weak-reference solution but a more robust -- i.e.,
> less dependent on code doing "the right thing" -- solution seems
> desirable.

Probably you can move the cleartable call above the marktmu call, but
you also need to keep another call in the original position. The marktmu
phase (and following propagateall) may ressurect some weak table that
will have to be cleared too. See next example:

local u = newproxy(true)
-- __gc metamethod should be collected before running
setmetatable(getmetatable(u), {__mode = "v"})
getmetatable(u).__gc = function (o) os.exit(1) end  -- cannot happen
u = nil
collectgarbage()


-- Roberto