https://github.com/soniex2/lua-using
using() function for Lua.
https://github.com/soniex2/lua-using
Last synced: over 1 year ago
JSON representation
using() function for Lua.
- Host: GitHub
- URL: https://github.com/soniex2/lua-using
- Owner: SoniEx2
- License: mit
- Created: 2015-11-13T16:20:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-13T17:01:13.000Z (over 10 years ago)
- Last Synced: 2025-02-04T11:48:29.975Z (over 1 year ago)
- Language: Lua
- Size: 0 Bytes
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lua-using
using() function for Lua.
## Examples
Program:
```lua
local using = require"using".using
local mt = { __gc = print }
local function example()
using(setmetatable({}, mt), function(file, func)
error("the file should get cleaned up")
end)
end
xpcall(example, print)
print "did we cleanup? yes!"
```
Output:
```
table: 0xe5d010
./using.lua:11: example.lua:7: the file should get cleaned up
did we cleanup? yes!
```