[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [Patch] Finalization of function objects
- From: Thomas Harning <harningt@...>
- Date: Tue, 22 Jan 2008 21:16:37 -0500
Nodir Temirhodzhaev wrote:
Has there been any work on enhancing this? I've found a few glitches on
another machine that I haven't had the chance to get the code from...
> Luiz Henrique de Figueiredo sent:
> "Finalization of function objects" patch for Lua 5.1.2
> What is the rationale for this patch?
For rationale see this old article:
"Generic: Change the Way You Write Exception-Safe Code - Forever" (
Patch is naive implementation of this idea and hint for Lua team.
Examples from memory...
Adding a finalizer for non-error then one for error... something 'wrong'
print"-- Finalize on error"
local function add5(x)
finally(x, print, false)
finally("Z", print, false)
finally("Z", print, true)
return x + 5
assert(not pcall(add5), "Error expected")
-- Finalize on error
Another error I recall is when an error is thrown from a coroutine... no
finalizers are executed in that case....