News for hackers. Stuff that matters.
Re:C: Simple Defer, Ready to Use by quelsolaar on Monday January 06, 2025 @05:14PM (#42616594)
...and a we would get a host of new bugs that would be a lot harder to fix. Invisible jumps are very bad.
Re:C: Simple Defer, Ready to Use by bangaladore on Monday January 06, 2025 @05:41PM (#42616895)
Nearly every modern language supports defer in some sense. Unless you are talking about RAII hiding the defer, but that's not the case with a custom Defer type or similar that takes a closure in the constructor.

Defer is a way better solution than having to cleanup in every single failure case.

Re:C: Simple Defer, Ready to Use by jefbyokyie on Monday January 06, 2025 @07:34PM (#42617844)
> cleanup in every single failure case

you're only tempted to clean up [fully] in every single failure case if you don't know how to implement cascading gotos or the arrow pattern.

Re:C: Simple Defer, Ready to Use by bangaladore on Monday January 06, 2025 @10:00PM (#42618687)
I'll be honest that you are in the minority here.

goto is widely considered an anti-pattern and so is the arrow pattern.

Re:C: Simple Defer, Ready to Use by jefbyokyie on Tuesday January 07, 2025 @01:09PM (#42625386)
> you are in the minority here

Yes, I am.

Re:C: Simple Defer, Ready to Use by jefbyokyie on Monday January 06, 2025 @07:33PM (#42617837)
> Invisible jumps are very bad

Agreed; they're terrible. Implicit sucks, explicit rules.