Closed HenrikBengtsson closed 9 years ago
This is because the registered finalizer calls finalize(<object)>
via the generic function (defined in R.oo), which in turn dispatches on class. It is not documented from within which environment the finalizer is called, but I'm pretty sure it's the global environment (recalled from some private emails with R core). Since finalize()
for Bar
is in a local environment, this will never be found/dispatched on. Hence, the finalize()
call will fall back to the default one for Object
which does nothing.
I'm not sure if there is another solution to this, unless one ties the finalizer to the actual object.
This one does not seem to be solvable under the current design. Leaving it as is for now.
EXAMPLE:
will output
Note how the Bar finalizer is never called.