Hi Ilija and Larry,
thank you so much for your great work bringing PHP forward. I have been passively reading this list
for a while and would like to chime in with two thoughts.
> Pipes would no longer have the form of expr |> expr, where the right-hand-side is expected
> to return a callable. Instead, it would have the form of expr |> function_call, where the
> left-hand-side is implicitly inserted as the first parameter of the call.
>
>namespace Iter {
> function map(iterable $iterable, \Closure $callback): \Iterator;
> function filter(iterable $iterable, \Closure $callback): \Iterator;
>}
>
>namespace {
> use function Iter\{map, filter};
>
> $result = "Hello World"
> |> str_split()
> |> map(strtoupper(...))
> |> filter(fn($v) => $v != 'O');
>}
With named parameters, you could even make this approach work without the suggested (but still
useful) new Iterator API:
$result = "Hello World"
|> str_split()
|> array_map(callback: strtoupper(...))
|> array_filter(callback: fn($v) => $v != 'O');
or
$result = "Hello World"
|> str_split()
|> array_map(callback: strtoupper(...))
|> array_filter(fn($v) => $v != 'O');
I am also wondering whether |> and -> should have the same operator precedence.
Best regards,
Olaf Schmidt-Wischhöfer