Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Which definitely does weird things in a loop.


IIFEs trivially solve that.

tbh I see FAR more range-var-misuse with Go loops than defers. I've seen over 100 range-var problems, and seen lints catch many more (several thousand), but I've only seen a loop defer issue once. When a defer is needed, it seems like people both remember the issue better (`defer` is a new construct for many, `for` is not and habits from other languages can mislead them), and the code is complex enough to justify a helper func, where a defer is trivially correct.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: