Re: Pipe Operator v2

From: Date: Thu, 26 Jan 2017 21:22:45 +0000
Subject: Re: Pipe Operator v2
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-97976@lists.php.net to get a copy of this message
On Thu, Jan 26, 2017 at 1:56 PM, Rasmus Schultz <rasmus@mindplay.dk> wrote: > Besides, I mean, I'm sure this has occurred to everyone, right? > > > https://gist.github.com/mindplay-dk/4ef61fd5c0a35e5aa8fc699febb86487 > > I personally find that this new syntax you're proposing requires a lot of > parsing. > > I mean, whenever you see substr() or array_map() etc. you're intuitively > expecting the first argument to be the first argument, right? Now you have > to backtrack through other lines and figure out the context, or try to spot > the $$ and count arguments to figure out which is which. I didn't follow this. Here is the example from your gist written with either Sara's or my proposal: $output = $input |> array_filter($$, function($n) { return $n % 2 == 0; }) |> array_map(function($n) { return $n ** 2; }, $$) |> array_reduce($$, function($x, $y) { return $x + $y; }) ; Maybe you can explain it a bit more with this code?

« previous php.internals (#97976) next »