3 ms·
Closures are poor man's objects and objects are poor man's closures. Same with RAII and defer. You can pretty easily map code using one to code using the other.
by hansvm 4y ago
Closures are poor man's objects and objects are poor man's closures. Same with RAII and defer. You can pretty easily map code using one to code using the other. Is init/deinit/defer that conceptually different from RAII?
- pjmlp 4y agoOnly in regards to enforcement, init/deinit/defer require help from static analysis to guarantee they aren't forgotten to be called for resources in block scope.