On Fri, 7 Feb 2025, 21:27 Thomas Hruska, <thru...@cubiclesoft.com> wrote:
> The repeated assignment to $temp in your second example is _not_ > actually equal to the earlier example as you claim. The second example > with all of the $temp variables should, IMO, just be: > > $temp = "Hello World"; > $result = array_filter(array_map('strtoupper', > str_split(htmlentities($temp))), fn($v) { return $v != 'O'; }); > Tbh, this is unreadable. Larry's example with an intermediate variable is a magnitude times more readable. This is exactly why we need pipe operator. I also consider the above compact code to be plenty readable and not > particularly necessary to span multiple lines, but that's obviously > subjective. > It is not, the functions are being applied from in to out (or right to left), which become hard to read with addition of each new function. Pipe operator makes it natural as they are applied from left to right which is how you read code, literally 0 cognitive load. Just because someone _can_ do something doesn't mean that they should. > More than likely, users trying to do pipe-like operations in PHP > shouldn't be doing them in the first place. > Why not? It clearly makes code more readable and in future with PFA (🤞) will allow composing non-unary functions. PHP is and always has been a multi paradigm language, there is no reason to not add stuff which makes using functional paradigm easier. Kind regards, Faizan