Hacker News new | ask | show | jobs
by tastysandwich 1100 days ago
Really glad to see some of these new packages (sort, map, etc) making use of generics. Should reduce the need for a lot of helper functions.

Also really excited to see loop capture variables finally getting sorted out. It is a constant pain point with new devs, and I have no good answer when they ask "but WHY is it like this?"

More information about loop capture here for those interested https://github.com/golang/go/discussions/56010

1 comments

> "but WHY is it like this?"

Because, historically, it's been like that all over, it's not just Go. For example, Python has the same loop variable reuse.

Probably comes from a time when compilers were a lot simpler, and all local variables were allocated stack space for the whole duration of the function call.