Functional Error and Optional-value Handling with STX
summary
STX is a header-only C++ library (no-std, no-RTTI, no-exceptions) providing a configurable panic handler with runtime hooks and compile-time defaults, plus option and result monads that supply map/match/or and expect methods and customizable error reporting. A try-style macro auto-propagates errors without exceptions. Results omit copies for fast return-by-value. Benchmarks show exception-based error paths incur huge slowdowns (example: ~554% latency increase on failure), while STX results run as fast as traditional error-code approaches.
AI-written summary · about
chapters (29)
- 0:00Intro
- 1:59Embedded Systems Design Space
- 4:25Introduction to STX
- 5:06STX Libraries
- 5:47Motivation #1
- 8:09Fatal Failures
- 8:57Fail-fast Abandonment Today
- 12:50Abandonment Expectations in the Wild
- 13:47Managing Abandonment Expectations
- 15:50Panic Function
- 17:03Panic example (backtrace enabled)
- 17:42Panic Handler
- 19:17Panic Behaviors
- 20:58Panic Hooks Example
- 23:55Optional-value Handling in C++ Today
- 24:29std::optional issues
- 27:35Option Constructors
- 27:56Option Example
- 29:49Option as a Type Monad
- 31:36Error Handling in C++ Today
- 32:18Exceptions Considered Harmful?
- 35:32What Problems Did Exceptions Solve?
- 38:17Result Constructors
- 39:24Result Example
- 41:12Error-propagation with TRY_OK
- 43:35Error-reporting with Custom Types
- 45:44Variant Benchmark Code
- 46:05Exceptions Benchmark Code
- 46:17C-Style Benchmark Code
related talks
59m“The Exception Situation"
01h 00mThe Dawn of a New Error
01h 13m"Mostly Invalid": flat_map, Exception Guarantees, and the STL
01h 35mMongrel Monads, Dirty, Dirty, Dirty
59mSoftware Engineering Is About Tradeoffs
54mMonadic Operations in Modern C++: A Practical Approach
55m“Using Types Effectively"
23mAutomatically Detecting Error Handling Bugs Using Error Specifications
