Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99459 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80133 invoked from network); 8 Jun 2017 17:21:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jun 2017 17:21:20 -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.82 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.82 mx101.easyname.com Received: from [77.244.243.82] ([77.244.243.82:43186] helo=mx101.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/94-27119-F8789395 for ; Thu, 08 Jun 2017 13:21:20 -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 1dJ17S-0007di-Vm; Thu, 08 Jun 2017 17:21:16 +0000 References: <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> <4FBDE643-1EBC-485A-A39F-7E28C5D4807A@koalephant.com> <40dc6de9-7e05-e043-e8e3-9e93409be2bd@fleshgrinder.com> To: php-internals , "rasmus@mindplay.dk >> Rasmus Schultz" Message-ID: <1db8ba6d-3020-e32a-8005-3e3072803ea5@fleshgrinder.com> Date: Thu, 8 Jun 2017 19:21:02 +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: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fFfN1FMUnTPakhPKQJNb6LrhwU28IqsAN" X-DNSBL-PBLSPAMHAUS: YES Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: php@fleshgrinder.com (Fleshgrinder) --fFfN1FMUnTPakhPKQJNb6LrhwU28IqsAN Content-Type: multipart/mixed; boundary="LNpQxOlVBcKaT3ft5C2DX06JsG0tXdWXR"; protected-headers="v1" From: Fleshgrinder To: php-internals , "rasmus@mindplay.dk >> Rasmus Schultz" Message-ID: <1db8ba6d-3020-e32a-8005-3e3072803ea5@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions References: <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> <4FBDE643-1EBC-485A-A39F-7E28C5D4807A@koalephant.com> <40dc6de9-7e05-e043-e8e3-9e93409be2bd@fleshgrinder.com> In-Reply-To: --LNpQxOlVBcKaT3ft5C2DX06JsG0tXdWXR Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 6/8/2017 6:28 PM, Rasmus Schultz wrote: >> it could be a single symbol instead of two >=20 > even if this can be done without parser ambiguity, it suffers from visu= al > ambiguity with the assignment operator. >=20 > consider what this would look like if the expression itself uses the > assignment operator... >=20 > f($x) =3D $y =3D $y + $x; >=20 > versus something like: >=20 > f($x) =3D> $y =3D $y + $x; >=20 > even that is visually ambiguous when used in arrays though: >=20 > $a =3D [ > "foo" =3D> f($x) =3D> $y =3D $y + $x, > ]; >=20 > also unreadable. >=20 > even if the parser can cope, I think we need some other symbol that isn= 't > visually ambiguous when used in these contexts? >=20 Absolutely, yes. One thing that could work is a combination of colon and equal sign with an optional type in between: f($x, &$y):=3D $y =3D $y + $x f($x, &$y): int =3D $y =3D $y + $x Still, kind of ambiguous if used with a type. Earlier I used the greater than sign only: f($x, $y)> $x > $y f($x, $y): bool > $x > $y As we can clearly see, also not optimal. A thing that should work is a hyphen greater than: f(object $o)->$o->property Looks weird without proper spacing, but with proper spacing ... f(object $o) -> $o->property =2E.. it looks fine, imho. Of course, we still have the other options tha= t were mentioned earlier already: f ~> 42 // bad on some keyboard layouts f =3D=3D> 42 // I personally do not like this option Another possibility is to use a keyword. This would definitely avoid symbol soup and help visual recognition: f do 42 f($x) do $x^3 f($x, &$y) do $y =3D $y + $x However, I am very unsure about this option to be honest. I'd say my choice here is `~>` but I'm on a US layout, second is `->`. Note that the latter is used in Java, Elixier, Erlang, Haskell, Julia, OCaml, F#, and probably others. --=20 Richard "Fleshgrinder" Fussenegger --LNpQxOlVBcKaT3ft5C2DX06JsG0tXdWXR-- --fFfN1FMUnTPakhPKQJNb6LrhwU28IqsAN 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 iQIcBAEBCAAGBQJZOYeDAAoJEOKkKcqFPVVrarEP/3MQQtDl/5oRryn0bHNeI/cn kVSwoHnVgbIZvEnTKn04doCT7n7uBJAWa2d3uC8rbVAPqmvCtrvYFsOppXsqD9I+ MRy8n+ryuVhCN7wfq6Cv63PyQedzNXV6FmJKX6ua0GMFzszZuoPU6unCA7Ebu1P7 BZRjdCPHYO07a2ehBqq6AM+7Y4+XlnD6UhCbh5NfY+2DlFL0pegXuVUAiKe1aUoi S9LFP11hJOXlitpQ9/I+ojaY0jJZC4deJ/82qItT98s6wtrloakOwYtW/smTshWN FAnEqYiB4RuiOflns5iwKZZLllaP8IJcbiuwkWIYxv6CXzcL4cAL25iiHHYbl/kh ArCyzU+O/BDp7u5rjHwK840UMVRAOITGAlqmxmDPdqYfvHVQAuAMpriGCIR7h489 DUWVj9D8gxJsfzqkU7AXS4+d6LowlXnaMDMAQBG+VEHDLIje7ANW3LLwkwPse9Id zu6xuXJSiCf2BD37TbzBjS5V/L8Y6drq9MpI0STVTIyNabt+Zhz10zXZSLJ3LSUp 9SIzFn7ZO+qzfoPCvgkGbhoFCrQPP24EUKCwoRlp/BcXcb1sLQmcf8MSLs+OeQHL e2BUbsmM3uaadkPVgXDLfjyEEtdPORq+Gf8E35SFR+1yfET8TOkg9JFlMfkM81eA XcpgcE/+c4diB8aJ0t26 =Fs8h -----END PGP SIGNATURE----- --fFfN1FMUnTPakhPKQJNb6LrhwU28IqsAN--