Is there a way for C to reference an object in Lua 5.2 in the same way that you would use the reference system except that these references are weak and may be garbage collected at any time? In other words, is there a registry of all current Lua objects that does not influence the objects' reference count?
You can do this by introducing one level of indirection - instead of storing the values directly in registry and forcing it to be weak, do this:
{__mode = "v"}
Note that there is no "track of all Lua objects" (like ObjectSpace in Ruby), unless you use some heavy persistence like Pluto. You can only access objects you store/track yourself.