News for hackers. Stuff that matters.
Re:I stopped everything and started writing C again by Capricorn2481 on Wednesday March 12, 2025 @08:30PM (#43349207)
Zig has defer, which is arguably way simpler. Is there something RAII can do that defer can't?

Not everyone likes RAII by itself. Allocating and deallocating things one at a time is not always efficient. That is not the only way to use RAII but it's the most prevalent way.

Re:I stopped everything and started writing C again by IX-103 on Wednesday March 12, 2025 @09:35PM (#43349545)
defer can't emulate the destructors of objects that outlives their lexical scope. Return values and heap objects are examples of these since they outlive the function they were created in. defer only supports enqueuing actions at lexical boundaries.

If you destroy an object that outlives the lexical scope it was created in, then you have to clean up manually.

Re:I stopped everything and started writing C again by tcfhgj on Thursday March 13, 2025 @05:03AM (#43351461)
Defer can be omitted