I think it’s worth noting that the people most excited about arrow functions are probably the ones with a more functional approach. Those kinds of side effects are usually avoided.
I also have nothing against capturing by reference. Given the last example: fn($item) => $array[] = $item All you have to do is glance a few characters to the left to see that $array is not a parameter and thus must be captured. And again, since it’s pretty obvious to see if you’re mutating the variable (spot the equal sign) this shouldn’t cause too many surprises. Only scenario I can think of is passing it to another function as a reference. But then again, no one ever complains about that in other languages. Ilija On 31 May 2017, 23:11 +0200, Levi Morrison <le...@php.net>, wrote: > > I can’t think of a scenario where capturing by reference would be helpful in > > a single line closure. > > function($item) use($array) { > return $array[] = $item; > } > > It's actually one of the first closures I discovered in the wild when > looking for closures that would be candidates for the short form.