lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Mar 23, 2009 at 9:28 AM, Roberto Ierusalimschy wrote:
>> On Sat, Feb 14, 2009 at 8:11 AM, Nodir Temirhodzhaev wrote:
>> > Patch for Lua 5.1.4:
>> > http://lua-users.org/files/wiki_insecure/users/tnodir/lua-5.1.4-finpatch.tar.gz

This is a followup of [1-2] :)  Here's a test:

  local function test()
    do
      finally(function() print '2' end)
      print '1'
    end
    finally(function() print '4' end)
    print '3'
  end
  test()
  print '5'

I expected 1 2 3 4 5, but the result was 1 3 4 2 5.  I think this is
by design as seen in "Manually finalized block" in test.lua.  It only
cleans up on function exits, not arbitrary block exits.

[1] http://lua-users.org/lists/lua-l/2009-01/msg00333.html - "state of
the Lua nation on resource cleanup"
[2] http://lua-users.org/wiki/ResourceAcquisitionIsInitialization