News for hackers. Stuff that matters.
Re:A Defer Mechanism for C by fnord123 on Monday December 14, 2020 @03:38PM (#25422946)
RAII is a delight when it comes to local heap memory. However, if you want to pair fclose with a fopen call then you need to wrap fopen in a type and make the destructor call fclose. This is totally fine and I like it a lot in C++ and Rust, but it doesn't gel with existing C apis. Therefore I think defer is a good choice for C regardless of what I might choose were I to be implementing a language from scratch.

There are no comments on this comment yet.