News for hackers. Stuff that matters.
Re:A Defer Mechanism for C by fishywang on Monday December 14, 2020 @12:11PM (#25419993)
Doing defer in a loop is usually a bug in your Go code. Sure there are legit use cases of it, but in ~90% of the time what you really want to do is (in Go, I haven't used C recently so not sure how to do lambdas correctly):

    for i := 0; i < 10; i++ {
      func(i int) {
        defer foo(i)
        // other code
      }(i)
    }

There are no comments on this comment yet.