Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93052 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31729 invoked from network); 3 May 2016 20:35:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 May 2016 20:35:33 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 212.232.25.164 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.25.164 mx208.easyname.com Received: from [212.232.25.164] ([212.232.25.164:58043] helo=mx208.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/A8-03860-29B09275 for ; Tue, 03 May 2016 16:35:31 -0400 Received: from cable-81-173-133-226.netcologne.de ([81.173.133.226] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1axh2T-0003Mp-U0; Tue, 03 May 2016 20:35:26 +0000 Reply-To: internals@lists.php.net References: <4fc01507-3d07-2309-a4e4-4cad7325249b@gmail.com> <39071a01-a42c-0952-b3a8-b4769c79b56b@fleshgrinder.com> <0ac3be89-6fb4-610a-ef89-0928f264f96c@fleshgrinder.com> <71379db5-b7b8-78b3-ada5-eee34e6e22d6@fleshgrinder.com> To: Ryan Pallas , "internals@lists.php.net" Cc: Sara Golemon , Terry Cullen , Stephen Coakley Message-ID: Date: Tue, 3 May 2016 22:35:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oJsJrAVAWtloLJEblqwfDuJpHoOWG0tBq" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC] Pipe Operator From: php@fleshgrinder.com (Fleshgrinder) --oJsJrAVAWtloLJEblqwfDuJpHoOWG0tBq Content-Type: multipart/mixed; boundary="DtiiObkE4w2xfdJehiju4w7xmvSbMN4PJ" From: Fleshgrinder Reply-To: internals@lists.php.net To: Ryan Pallas , "internals@lists.php.net" Cc: Sara Golemon , Terry Cullen , Stephen Coakley Message-ID: Subject: Re: [PHP-DEV] [RFC] Pipe Operator References: <4fc01507-3d07-2309-a4e4-4cad7325249b@gmail.com> <39071a01-a42c-0952-b3a8-b4769c79b56b@fleshgrinder.com> <0ac3be89-6fb4-610a-ef89-0928f264f96c@fleshgrinder.com> <71379db5-b7b8-78b3-ada5-eee34e6e22d6@fleshgrinder.com> In-Reply-To: --DtiiObkE4w2xfdJehiju4w7xmvSbMN4PJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 5/3/2016 10:22 PM, Ryan Pallas wrote: > I have to disagree, I haven't seen an example of rewriting the original= > example from the RFC in a more expressive AND readable way. Yes, you ca= n > use lots of intermediate variables, but this makes the code HARDER to r= ead > QUICKLY which is entirely the point of a syntatic sugar addition like t= his. > Syntactic sugar makes a language sweeter, and more palatable. Like cane= > sugar makes your cookies taste good, but doesn't make them more nutriti= ous. >=20 Opinions you know but I am still waiting for that example. On 5/3/2016 10:22 PM, Ryan Pallas wrote: > This breaks dependency injection, and makes testing harder. You now de= pend > on an array of data which is accessed internally, and can only minimall= y > control it's contents in a testing environment. >=20 Why do you need dependency injection in the most outer point of your application? This should be tested with your acceptance/integration tests and nothing else. How many unit tests have you written for your Symfony app kernel lately? A rather extreme example of such a /most outer/ but you know how it is with constructed examples: http://www.yegor256.com/2014/10/03/di-containers-are-evil.html#the-right-= way On 5/3/2016 10:22 PM, Ryan Pallas wrote: > Again, how do I dependency inject a config during testing to make sure = I > build the dic correctly? I'm assuming you're using a bunch of temporary= > properties? Also you just made adding a step significantly harder, what= if > from building the app, I need to build another layer build for the rout= er, > for |> I add ONE line of code, for yours I edit the build function in t= he > right location, and change the build router function to load from a > different property, and build another boilerplate function to build thi= s > new thing, and add another property to hold this new thing... WHOA that= 's a > lot more steps, and a MUCH higher risk of a mistake! >=20 Again, this is the most outer place of everything. I mean, all frameworks and applications were and are able to solve these issues easily, nicely, and testable. Just because my /proposed/ solution to an example that is constructed in the first place is not as nice as those solutions does not make the examples better. :P On 5/3/2016 10:22 PM, Ryan Pallas wrote: > Again, you're solution is to use OOP, but the pipe operator's purpose i= s to > make procedural code cleaner. Not one of your solutions maintained a > procedural interface, and therefore is not an argument against the |> > operator. The purpose of this operator is syntactic sugar, which "is sy= ntax > within a programming language that is designed to make things easier to= > read or to express. It makes the language "sweeter" for human use: thin= gs > can be expressed more clearly, more concisely, or in an alternative sty= le *that > some may prefer*."[1] (emphasis mine). Its not designed to solve a prob= lem > of how can I do this thing, but how can I write this thing such that my= > team might be able to understand it better. >=20 > Yes, you can rewrite these examples in an entirely different way, but n= ow > you're not comparing apples to even other fruit (procedural vs OO is no= t > the same). The point of this is to take a very common pattern (nesting = many > procedural calls) and make it easier to read and manage later. >=20 foreach (scandir($arg) as $path) { if ($path !=3D=3D '.' && $path !=3D=3D '..') { $ret[] =3D getFileArg($arg . DIRECTORY_SEPARATOR . $path); } } What can I say ... --=20 Richard "Fleshgrinder" Fussenegger --DtiiObkE4w2xfdJehiju4w7xmvSbMN4PJ-- --oJsJrAVAWtloLJEblqwfDuJpHoOWG0tBq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXKQuIAAoJEOKkKcqFPVVryCgP/iD0+/6RFCUArM2oxzVhFnfz 1dPiPwjhPx3XPPPFwF8ndlTx/ObAEH+3l9EX7ANCl7s5MD2sdKSV8zOc1iUuAVVq vhytGqS8M/kD8ykOfWXqBfPfHWD6taH048ULot2YTQDsR1CI2wGW/dcGx+TUif/M kWFUVMBVKgSuUERaCQ8wLmi5KgelnFUuReQJM1xRS5kkNR2gwFxxg8FRdJqVge6O WKHOVMVXx2wQgwgLGmE50A0b+Kr4UowPzOzulQSbLa0cXeHkf/fyfmwQUwZqR6fd QMCH8+qMTdsLPp657hfnfd3a6HM4M2dq5LlN43KUeN8P4RoFC3mBxz5QSa/V7Js6 iNsgQWCSqUdT3ax5h+fRInw23No4bdI0GNNwc+JP60NlRW//BupnSiNg8KHl89X3 tgLE4ALaJIgcRs32EyqJGZxSXw1PTcq1Ah71/tQIgZ2Ohu5tkE4usG0rwlKVMUDx 9y9h1BIQ8//tHAWtSdLzF2SBQyoNih7FUWSlEcD389eZ8l3/ESW9YdBpn13qAqAG /Lr3W5ITBmBli5acDUtmp/Y83FLVbiGpXPrlOngqBQTEjIxQTWyQjjISfc4vBDuq b3F/SYpTRN+ArBTbODUzR3G6wJKC8R+gnmEngzT7+Owi5TaP7QIZLZCSLj25HHql NIHqpYylYtQhWRaRmrfM =Evxi -----END PGP SIGNATURE----- --oJsJrAVAWtloLJEblqwfDuJpHoOWG0tBq--