News for hackers. Stuff that matters.
Re:C++ For C Programmers by archangel_one on Monday October 14, 2013 @07:35AM (#6546626)
Exceptions and RAII match well, actually. Managing resources via RAII means that when an exception is thrown, the destructors of local objects are invoked so they'll release resources they've acquired.

In fact, I'd argue that you very often have to use RAII with exceptions, since there's no 'finally' block on a try-catch statement and hence it's the easiest way to ensure stuff gets cleaned up (well, except for catch(...) and rethrowing, but that's kinda ugly).

Re:C++ For C Programmers by eliasmacpherson on Monday October 14, 2013 @08:19AM (#6546766)
correct me if I am wrong but you can't rethrow in a destructor and hence RAII is required if you are using exceptions - because the cleanup and reporting work must be done in the destructor - unless you use global state to track failures and check after every attempted release of a resource i.e. C error checking.