6 ms·
yeah, I've always just extracted the loop body into a new function as a result
by chrsig 2y ago
yeah, I've always just extracted the loop body into a new function as a result
- infogulch 2y agoI've created a lambda and called it inline to force lexically scoped defer semantics. Works fine and reads fine imo.
- chrsig 1y agoI've definitely done that as well. I generally don't have a problem with it, but it makes for an extra conversation the first time someone sees the pattern. Given how some of the other ergonomic changes in go have gone (closures capturing loop variables, for instance), I'd support a change to lexical scoped defers if it were on the table.