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

RAII works just as well for heap allocated objects as it does for stack allocated ones.


Sure, but allocating resources on the stack is not good for maintainability. Software is easier to understand if its state is not hidden in semi-permanent call stack frames.


In general I agree with you, but that seems orthogonal to the subject at hand.


Parent's statement was that early returns are hard because you need to cleanup allocated resources. I don't think so, because there shouldn't (usually) be resources "on the stack".


But RAII is orthogonal to auto, static, or dynamic allocation.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: