Bjarne fix your freaking language
11 days ago
- #Error Handling
- #RAII
- #C++
- Bjarne Stroustrup demonstrates unsafe C code with potential resource leaks due to missed cleanup.
- RAII in C++ is introduced as a solution to ensure resource cleanup, using a File_handle class with a destructor.
- C++ exceptions have issues: correctness, exhaustiveness, and RAISI (Resource Acquisition is Second Initialization).
- Error handling in C is straightforward with NULL checks, while C++ exceptions complicate error reporting.
- RAII with exceptions requires RAISI, leading to more complex code and potential uncaught exceptions.
- Alternative techniques include handling errors before RAII or using side-channels like error_code.
- Simplified File_handle class without exceptions reduces complexity and improves error handling.
- Herb Sutter's talk and a related paper discuss further improvements to C++ exceptions.