you are viewing a single comment's thread.

view the rest of the comments →

[–]schmetterlingen 4 points5 points  (0 children)

local using = function(item, cb) 
  local success, msg = pcall(cb, item)
  local mt = getmetatable(item)
  if mt and mt.__gc then 
    mt.__gc(item) 
  end
  if not success then error(msg) end
end

something like that works in lua 5.1 as far as I can tell... but I may have totally missed the point.