Note, sorry but this article is going to skip between languages a bit. If you work in PHP, you likely know what they do and how to use them…
What prompted this article is that I was just working on a “function stack” of anonymous that other processes can add to, and I used this because of the “You can’t add to an array inside a foreach” issue; and a colleague saw it and said “what the devil is that?!?”
This stems from the fact that foreach grabs the key of “last” to compare to for its loop.
So many of its structures correspond to assembly in ways that should have made it really easy to make it run fast.