News for hackers. Stuff that matters.
Re:Implementing Go's defer keyword in C++ by loeg on Saturday October 21, 2017 @11:24PM (#15525016)
It allows you to keep the cleanup next to the allocation/initialization, which is a nice organization. It's easy to ensure you haven't forgotten to clean something up in any exit path.

(Obviously, classic RAII has pretty much the same benefit. But it requires a whole class per type, whereas this approach has less boilerplate.)

There are no comments on this comment yet.