Skip to content

basiliscos/lua-scope

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
t
 
 
 
 
 
 
 
 
 
 
 
 

lua-scope

lua-scope is simple Resource Acquisition Is Initialization implementation for Lua.

Build Status

Synopsis

local scope = require "scope"

scope(function(guard)
    local f = assert(io.open("out", "w"))
    -- always executed at the end of the function
    guard:on_exit(function() f:close() end)
    -- might die or might not
    do_more_stuff(f)
    
    local f2 = assert(io.open("out", "w"))
    -- some other protector
    guard:on_exit(function() f2:close() end)
    do_more_stuff_2(f2)
end)

Installation

luarocks install luascope

About

Resource Acquisition Is Initialization implementation for Lua

Resources

License

Stars

Watchers

Forks

Packages

No packages published