On 2026-01-31 18:52, Vadim Dvorovenko wrote:
Introducing Pipe to return RFC

https://wiki.php.net/rfc/pipe_to_return

In short, RFC proposes piping expression result to `return` to be used together with pipe operator to reduce cognitive load

"Hello World" |> strlen <http://www.php.net/strlen>(...) |> return;

--

Vadim Dvorovenko


I'm wondering how this would relate to the function composition operator, noted in the follow-up RFC. Basically, would "return" make sense at the end of a function composition chain, and what sense would that be?

When $x |> f1(...) |> f2(...) |> f3(...);
is equivalent to (f1(...) + f2(...) + f3(...))($x);
[Aside: personally I find the suggested order of arguments backwards from every other instance of function composition I've encountered, but I suppose I could learn to live with it. But that's another subject.]

and $c = f1(...) + f2(...) + f3(...);
is equivalent to $c = fn($x) => ($x |> f1(...) |> f2(...) |> f3(...));

what happens when "f3(...)" is "return"? The intended behaviour is given for the first case but not for the others (not even the fourth, which is still the pipe operator).

Reply via email to