Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93027 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87341 invoked from network); 2 May 2016 02:48:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 May 2016 02:48:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=come@opensides.be; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=come@opensides.be; sender-id=pass Received-SPF: pass (pb1.pair.com: domain opensides.be designates 195.154.20.141 as permitted sender) X-PHP-List-Original-Sender: come@opensides.be X-Host-Fingerprint: 195.154.20.141 smtp.opensides.be Received: from [195.154.20.141] ([195.154.20.141:56703] helo=smtp.opensides.be) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A5/37-03860-A10C6275 for ; Sun, 01 May 2016 22:48:58 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.opensides.be (Postfix) with ESMTP id 0D200CC917 for ; Mon, 2 May 2016 04:48:55 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at opensides.be Received: from smtp.opensides.be ([127.0.0.1]) by localhost (smtp.opensides.be [127.0.0.1]) (amavisd-new, port 10024) with LMTP id MkEwxBlaCKjN for ; Mon, 2 May 2016 04:48:54 +0200 (CEST) Received: from mcmic-probook.localnet (node-11jw.pool-182-52.dynamic.totbb.net [182.52.190.28]) by smtp.opensides.be (Postfix) with ESMTPSA id EF0F1CC8BC for ; Mon, 2 May 2016 04:48:53 +0200 (CEST) To: internals@lists.php.net Date: Mon, 02 May 2016 04:45:46 +0200 Message-ID: <1921055.DcKiMG99xv@mcmic-probook> Organization: OpenSides User-Agent: KMail/4.14.1 (Linux/3.16.0-4-amd64; KDE/4.14.2; x86_64; ; ) In-Reply-To: References: <5723F4C4.6080207@garfieldtech.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Subject: Re: [PHP-DEV] [RFC] Pipe Operator From: come@opensides.be (=?ISO-8859-1?Q?C=F4me?= Chilliet) Le dimanche 1 mai 2016, 00:20:45 Dan Ackroyd a =E9crit : > However, it is not the proposed new syntax that makes the code more > readable - it is solely due to writing it in the correct order that > makes the code more readable. This can be done using current PHP > syntax, so that the code is: >=20 > $dirEntries =3D scandir($arg); > $files =3D array_filter($filesAndDirectories, function($x) { ret= urn > $x !=3D=3D '.' && $x !=3D '..'; }); > $fullPaths =3D array_map(function ($x) use ($arg) { return $arg . '/= ' . > $x; }, $files) > $fileInfo =3D getFileArg($fullPaths); > $ret =3D array_merge($ret, $fileListInfo); >=20 > Using the proposed new syntax to rewrite it without the intermediate > variables like this. >=20 > $ret =3D scandir($arg) > |> array_filter($$, function($x) { return $x !=3D=3D '.' && $x !=3D= '..'; }) > |> array_map(function ($x) use ($arg) { return $arg . '/' . $x; }= , $$) > |> getFileArg($$) > |> array_merge($ret, $$); >=20 > Does not now show a marked improvement in readability. Yeah, then why is the first code you wrote containing errors and not th= e second one? I have to read carefully the first one to see that the variables used i= n the code are not the same one returned from the line above. There is no need for this in the second one which is much clearer, each= call reuses the return from the function above. I had no opinion on this RFC until people started to explain using 100 = variables for such simple things is the best solution.