top | item 43418138

(no title)

chrsig | 11 months ago

yeah, I've always just extracted the loop body into a new function as a result

discuss

order

infogulch|11 months ago

I've created a lambda and called it inline to force lexically scoped defer semantics. Works fine and reads fine imo.

chrsig|11 months ago

I'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.