I don't think that anyone has mentioned this yet, but I guess you mean
something like this:
* put B in A's uservalue table to keep it alive as long as A is alive
* put a weak back reference to A in B's uservalue table
* in A's finalizer free A if it hasn't been freed before by someone else
* in B's finalizer first free A if the weak back reference still
exists and A hasn't been freed before, and then free B itself if it
hasn't been freed before
One thing I noticed is that the uservalue table of my objectA being
finalized in the _gc callback still has a reference to objectB, even
if objectB's _gc callback was invoked before this one. (I suppose this
is for if you need resurrection?)