I recommend reading my reply to another comment regarding RAII: https://news.ycombinator.com/item?id=32629951
Also the article itself demonstrates different approaches to achieve behaviour similar to RAII through the `defer` statement and `deferred_*` attributes.