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

Automatic resource management killed C for me. The need to write endless towers of explicit error checks, or endless goto cleanup, and making sure that you explicitly clean up things in the right order, is the programming equivalent of washing your dishes by hand instead of using a dishwasher.

Now, if C had something like Go's "defer"...



> Now, if C had something like Go's "defer"...

In GCC and Clang you can use __attribute__((cleanup)) to achieve this. I think MSVC has a similar construct.

I'm pretty sure I've seen a portable "defer" library for C somewhere.


> I think MSVC has a similar construct.

Microsoft rather focus in C++.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: