Excerpts from Philipp Janda's message of 2014-05-03 20:50:26 +0200:
I would split your object into two parts: One frontend handle, and one
backend stored via `luaL_ref` in the registry. The frontend handle (Lua
table in 5.2, proxy userdata in 5.1) forwards all calls the the real
thing and has a __gc that checks for reachability on "the other side".
If you are still reachable over there, you create a _new_ frontend
handle and put it into your weak table for the next garbage collection
run to check again. In case you aren't reachable on the other side
either, you `luaL_unref` the backend userdata, which will be collected
eventually.
This is the workaround I originally tried. Unfortunately it leaks
memory as you need to create and link chain new dummy object to get
another __gc notification after each resurrect incident.