3 ms·
To know that the returned function can keep state? And if it does, to easily scan for side-effects via modified state? And to do this without carefully reading
by nnq 13y ago
To know that the returned function can keep state? And if it does, to easily scan for side-effects via modified state? And to do this without carefully reading the entire body of the closure? It's a little bit like a "poor man's replacement for what a monad can be useful at" or `[Pure]` in C#. True, not much use in code you have written, but great for working with and even refactoring other people's code that you don't fully understand.
...to be honest, it's the kind of feature that I'd like to see in Javascript, not in PHP, to help me easily scan through callback hells in other people's code. It's true that callbacks don't tend to be abused in PHP and we don't have event labyrinths and long running event driven apps that can grow in memory usage, but these things will crop up, and when they do we'll have one less tool to make code more explicit and easier to read.
I guess the fate of all good ideas that land in PHP is to be ignored, hated and then forgotten :)