[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: newproxy() tricks
- From: steve donovan <steve.j.donovan@...>
- Date: Mon, 13 Dec 2010 09:19:58 +0200
Hi all,
I'm reviewing the FAQ for another release and came across this
confident statement:
[[
But there is an undocumented function, `newproxy` which creates a
little piece of 'userdata'. Here is a useful trick for writing a
module finalization function:
local finis = debug.setmetatable(newproxy(),{
__gc = function()
...your code goes here...
end
}
Then, when the value is finally garbage collected, your code executes
and does any module-specific clean-up.
]]
Nice ... if it were always true. But I have my doubts, and my feeling
is to drop this paragraph.
Any thoughts?
steve d.