[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Errors in finalizers (was: [ANN] Lua 5.4.0 (alpha-rc1) now available)
- From: David Heiko Kolf <david@...>
- Date: Tue, 4 Jun 2019 22:39:31 +0200
Andrew Gierth wrote:
>>>>>> "Roberto" == Roberto Ierusalimschy <roberto@inf.puc-rio.br> writes:
> Roberto> As Gé pointed out, propagating a finalizer error is pointless.
> Roberto> You are interrupting code that has nothing to do with the
> Roberto> error, and cannot know how to handle it.
>
> This. DOES. NOT. MATTER. to me. All that matters is that the error MUST
> NOT BE IGNORED.
But this is exactly what could happen when you throw the error in a
finalizer: The code might currently be in a pcall which doesn't expect
your finalizer error and therefor also doesn't react to it -- the code
following the pcall would continue as usual, you just skipped some
random code.
An example from actual code I have written:
pcall(function ()
local debug = require "debug"
-- I am now doing stuff with the debug library
end)
-- At this point I continue, assuming that the worst that could
-- have happened might be that I didn't get access to the debug
-- library. I don't even check the pcall result.
If an error during a finalizer occurs I would probably store it in some
list and regularly check that list (for example in library functions
that you know should not run as normal when a finalizer failed previously).
Best regards
David