https://github.com/basiliscos/lua-scope
Resource Acquisition Is Initialization implementation for Lua
https://github.com/basiliscos/lua-scope
Last synced: 10 months ago
JSON representation
Resource Acquisition Is Initialization implementation for Lua
- Host: GitHub
- URL: https://github.com/basiliscos/lua-scope
- Owner: basiliscos
- License: artistic-2.0
- Created: 2015-05-29T10:53:30.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-06T15:34:32.000Z (over 10 years ago)
- Last Synced: 2025-01-18T04:31:47.907Z (12 months ago)
- Language: Lua
- Size: 168 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
lua-scope
=========
*lua-scope* is simple Resource Acquisition Is Initialization implementation for Lua.
[](https://travis-ci.org/basiliscos/lua-scope)
Synopsis
=========
```lua
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```