News for hackers. Stuff that matters.
Re:A Defer Mechanism for C by coldtea on Monday December 14, 2020 @09:28AM (#25417905)
RAII is an idiom, not a language feature. Destructors might be the language feature, but they have their own issues and caveats.

So I don't see the comparison...

Re:A Defer Mechanism for C by isogon on Monday December 14, 2020 @10:03AM (#25418320)
I think it's quite reasonable to compare defer and destructors, in that case.

Destructors probably cannot be usefully imported into C while preserving the simplicity of the language: then you'll want at least unique_ptr to manage your memory with destructors, then probably shared_ptr, and some ownership semantics as you pass those around, et cetera. In that sense, defer strikes a balance between simplicity and usefulness. However, there is still a comparison.