Declarative Control Flow
Getting exception handling right is a perennial problem in C++ that has eluded systematization. Not for much longer. New language and library developments make it possible to handle exceptions in a declarative manner, leading to drastic code simplification.
This talk discusses an alternative approach to handling exceptional flow that eliminates the need for small ancillary RAII classes, try/catch statements that rethrow, and other cleanup mechanisms. The popular Scope Guard idiom gets a spectacular generalization. Statements specify in a declarative manner actions to be taken if the current scope is left normally or via an exception. The resulting code is simpler, smaller, and easier to maintain.
- Review ScopeGuard's pros and cons
- Stay abreast of proposed language improvements for better error handling
- New implementation-specific extensions to scope guards
- Use of the new SCOPE_FAILURE and SCOPE_SUCCESS abstractions that complements the existing SCOPE_EXIT
ScopeGuard is of interest to C++ programmers of all levels. Implementation details are appealing to advanced engineers.
- Action/Next/Cleanup/Rollback idiom overview in several languages
- Composition with said idiom
- Explicit vs. implicit control flow as a riff on declarative vs. imperative programming
- MSVC 8.0+
- Cake Candles
- Use Cases
- Transactional Work
- Order Still Matters
- nothrow notes
- Scope Changes
- Legacy code