Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99406 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25315 invoked from network); 6 Jun 2017 16:32:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2017 16:32:39 -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 77.244.243.86 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.86 mx105.easyname.com Received: from [77.244.243.86] ([77.244.243.86:48957] helo=mx105.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/E1-27119-429D6395 for ; Tue, 06 Jun 2017 12:32:38 -0400 Received: from cable-81-173-132-37.netcologne.de ([81.173.132.37] 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 1dIHPD-0001sD-BY; Tue, 06 Jun 2017 16:32:32 +0000 References: <6357d97c-3f2e-4cf8-cb1f-cb7f7ccccf7c@telia.com> <7eaef49b-bf60-9aa1-e812-8430164e3178@garfieldtech.com> <3F920987-38CB-42DD-888D-824430C36F14@gmail.com> <2f9e73c9-444a-11d0-459a-e261ea8a7080@telia.com> <4077c099-2247-c3c1-7dee-02a6b25f8586@fleshgrinder.com> <559b73f7-c40f-e593-f0e1-51b56210d7cb@telia.com> <2053A608-6B66-42FB-A6D7-7CC64E94DA6A@koalephant.com> To: php-internals , php-lists@koalephant.com Message-ID: <6558e48f-62d1-8157-a2ce-2f5b68af92f6@fleshgrinder.com> Date: Tue, 6 Jun 2017 18:32:17 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <2053A608-6B66-42FB-A6D7-7CC64E94DA6A@koalephant.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sC9CVvBaJonkmpgrGfou4fkAKIVMB0C3S" X-DNSBL-PBLSPAMHAUS: YES Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: php@fleshgrinder.com (Fleshgrinder) --sC9CVvBaJonkmpgrGfou4fkAKIVMB0C3S Content-Type: multipart/mixed; boundary="A8PljpsNrkMn0MT8mxsTRQuQn8XEoLuPT"; protected-headers="v1" From: Fleshgrinder To: php-internals , php-lists@koalephant.com Message-ID: <6558e48f-62d1-8157-a2ce-2f5b68af92f6@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions References: <6357d97c-3f2e-4cf8-cb1f-cb7f7ccccf7c@telia.com> <7eaef49b-bf60-9aa1-e812-8430164e3178@garfieldtech.com> <3F920987-38CB-42DD-888D-824430C36F14@gmail.com> <2f9e73c9-444a-11d0-459a-e261ea8a7080@telia.com> <4077c099-2247-c3c1-7dee-02a6b25f8586@fleshgrinder.com> <559b73f7-c40f-e593-f0e1-51b56210d7cb@telia.com> <2053A608-6B66-42FB-A6D7-7CC64E94DA6A@koalephant.com> In-Reply-To: <2053A608-6B66-42FB-A6D7-7CC64E94DA6A@koalephant.com> --A8PljpsNrkMn0MT8mxsTRQuQn8XEoLuPT Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 6/6/2017 6:38 AM, Stephen Reay wrote: > As someone who sees limited appeal in short closures (Ok, they may > make for slightly simpler constructs that are slightly too complex > for a regular =E2=80=9Ccollect=E2=80=9D type collection method), I see = a *lot* of > people spending a *lot* of time to save typing 8 characters > (function). >=20 > If this feature truly is about making it easier to read, then that > should be your goal: make it easy to mentally parse, basically > instantly. Given that even proponents of the approach are admitting > the syntax can get quite hard to understand quickly, perhaps it=E2=80=99= s > time to accept that =E2=80=9Cmore characters=E2=80=9D !=3D=3D =E2=80=9C= harder to read & > understand=E2=80=9D and importantly, =E2=80=9Cless characters=E2=80=9D = !=3D=3D =E2=80=9Ceasier to read & > understand=E2=80=9D. >=20 > How long does it take someone to type function? A second, maybe two? > How many times are other people going to read that, once it=E2=80=99s b= een > written? >=20 I can only agree once more. PHP is verbose, PHP always was verbose, PHP should stay verbose. Not to say that short closures are bad, but searching for the perfect symbol soup seems wrong. We could easily create a syntax that is totally unambiguous and easy on the parser without lots of look-ahead with a new keyword. fn> 42 fn($a, $b)> $a + $b fn($a) (&$b)> $b +=3D $a $a =3D [fn()> 42]; usort($data, fn(T $a, T $b):int> $a <=3D> $b); Our (simplified) production rule would be (where brackets denote optional= ): "fn" [ (" [P] ")" ] [ "(" U ")" ] [ ":" T ] ">" E P :=3D param list U :=3D use list T :=3D return type E :=3D expression (to return the result of) This would also ensure that nobody can use it for more complicated expression, since we are not supporting braces. Anything complex should continue to use the long closure notation, as it is more readable. Extending this for usage with methods would also be quite easy. In that case we can even drop the keyword (methods require a name anyways): final class SomeEnum { // ... public static Foo(): self > new static('foo'); public static Bar(): self > new static('bar'); } --=20 Richard "Fleshgrinder" Fussenegger --A8PljpsNrkMn0MT8mxsTRQuQn8XEoLuPT-- --sC9CVvBaJonkmpgrGfou4fkAKIVMB0C3S 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 iQIcBAEBCAAGBQJZNtkaAAoJEOKkKcqFPVVrHxEP/1Mm+6upsBMYvBqAHSJ1BQi/ gjzph1vpUGAYgWRQjJ6E7Hkko5CyaoxcQ7XVQGieQl3wYc0JZCOR1NUxV4BjV/Yr 5sUUYHggXvCiq6zp7dHE5aD2P+lUJJYowgPLyqHhz9hGDGP7ITTKgA9194Oh/aAL 5sfy3FTLrp3Hc4h2C9J0pU2MGzhhFrRTe6wYF2WuigHwIopSS+SXHvEwIRSPvgu1 2JGj01Mr0L3p1AdvYrQkjIsgsejUMMaK4Oc38FfEXgUhfHa2BrlvaLXbjtVmC7mf QhGnZnXYhCevlxetRmaf33zA2ESPwqwxdYEB1P9Nkxpdif2ejkUlV5jug1ndsJA9 KDdXGT0+nRck/6X0RGPnnza4iT7yoq10dhU3EFy062EZ3t/H5CJlkq6s3gn5Mi2s k8bBkxg/j0eI7eYgLLSYnQK7omVmb2X04/oBM3fdTna8DqdQ5rDdawAyOJZ6mCFt BwPiRQUqvnVW+ctBPovRzdT0NDNFL7A8t2oQcghinsy+b8e9u8X2eMmR3yL92RVT KeF/d1hYed5B/isxCgDVUBABUVNx5c1/WhcAHvtJDitoIH2KA8WoJij875SmPX8U 46fAJsjog5OheKRXLysXuAABzxlyV1C7mEDPlII1wPesuggLAbFZXeb5O7J2L/UZ 8O32P/Kjxgl2nIy22Tre =+Dmw -----END PGP SIGNATURE----- --sC9CVvBaJonkmpgrGfou4fkAKIVMB0C3S--