Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Not right there, some other place in the function.

Exactly. Both C++ RAII (constructors/destructors) and C23 defer are awful. They make the behavior implicit; in effect they tie an indefinitely large (and growing) baggage to scope termination without the source code reflecting that baggage.

Cascading gotos (or the arrow pattern) are much better. Cleanup code execution is clearly reflected by location in the source code; the exit path can be easily stepped through in a debugger.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: