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

In Go 1.22 as well, closures still capture-by-reference. The change is that there is now a new loop variable in each loop iteration, just like in OCaml. But two closures that refer the same loop variable (that are created in the same iteration, that is) will still see the changes each makes to that variable.

And what I was trying to show with my example was that this kind of behavior would be observable in OCaml as well, if it were to be implemented like that.



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

Search: