sbrm
v1.0.0
Published
Scope bound resource management (lisp's with pattern, c++'s raii)
Downloads
2
Maintainers
Readme
sbrm - scoped bound resource management
lisp has the with
pattern which is also present in python.
c++ has RAII (resource acquisition is instantiation).
there are 2 versions:
- scoped
scope(
() => new $class(),
(instance) => instance.release()
)(
(instance) => { /* use the instance */ }
);
- scopedClass
class A {
// acquire the object
static acquire() { return new A; }
// release object
static release(i) { i.release(); }
constructor() { /* acquire resources */ }
work() { return 1; }
release() { /* release stuff */ };
}
scopedClass(A)(
(instance) => { /* use the instance */ }
);