Dodging the Go loop trap

Ted Unangst:

And now we’re trapped. There’s only one friend variable, constantly changing as we go through the loop, with the most likely result one of our friends will get half a dozen messages, while the other five receive nothing, to the annoyance of both groups.

Funny that Perl got this one right when not only many before didn’t but many since also haven’t.

In Go, as Ted says, they may even change the language to fix it; in Javascript, they already have.

Leave a comment

About Aristotle

user-pic Waxing philosophical