Re: [RFC] Pipe Operator
| From: | Jesse Schalken | Date: | Tue, 03 May 2016 11:43:36 +0000 |
| Subject: | Re: [RFC] Pipe Operator | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-93039@lists.php.net to get a copy of this message | ||
I am very much in favour of this. I would typically write the example with
an intermediate variable to avoid all the sad nesting.
$files = scandir($arg);
$files = array_filter($files, function ($x) { return $x !== '.' && $x !==
'..'; });
$files = array_map(function ($x) use ($arg) { return $arg . '/' . $x; },
$files);
$files = getFileArg($files);
$ret = array_merge($ret, $files);
But it's certainly unfortunate that I had to revert from expressions
without state to ordered statements mutating a variable just to avoid
deeply nested parens. Anything that enables more code to be written
declaratively rather than imperatively is a win in my opinion, especially
if it can be implemented as mere syntactic sugar as is the case here.
On Sat, Apr 30, 2016 at 5:58 AM, Sara Golemon <pollita@php.net> wrote:
> This is one of my favorites out of HackLang. It's pure syntactic
> sugar, but it goes a long way towards improving readability.
> https://wiki.php.net/rfc/pipe-operator
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>