Skip to content

Instantly share code, notes, and snippets.

@siffiejoe
siffiejoe / transaction.lua
Last active November 18, 2015 00:31
Experimental Lua module for using transactions to manage resources.
--[[
local t = transaction( function( a, b, c )
if c then c:destroy() end
if b then b:clear() end
if a then a:close() end
end )
local a = t( f() )
local b = t( a:foo() )
local c = t( b:bar() )
-- do something with a, b, c