lua-users home
lua-l archive

newproxy() tricks

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


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.

AltStyle によって変換されたページ (->オリジナル) /