Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99311 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21044 invoked from network); 1 Jun 2017 16:58:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jun 2017 16:58:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=theodorejb@outlook.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=theodorejb@outlook.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain outlook.com designates 40.92.8.39 as permitted sender) X-PHP-List-Original-Sender: theodorejb@outlook.com X-Host-Fingerprint: 40.92.8.39 mail-oln040092008039.outbound.protection.outlook.com Received: from [40.92.8.39] ([40.92.8.39:8697] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/A0-12681-3A740395 for ; Thu, 01 Jun 2017 12:58:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=QwagcoDe17+7oUkw07BGb32tzKCiKZBu6EKgxASxu1I=; b=YGwNFazRmic5KlXBYx8n4+p8ahf9ERO1nkly0iuGKhHiQWchfppltMKMcX3raODUrw+kK2NaIhMO8XCU5+fO9vq9aDVi5gqioYRPoRmpSOV/lP10oU7Z2n+HKTeMGgtFfypuFU//ziHCoT0IG7OQEDtxEV9oR9dK/SdFKsX4Vk9/bdOtcadwsUBvAenlconYNajlk5I2Qsy7uBhe/009iBeItT8yUCUzU/R2k7aqjwxYdxL7kGFVLFeJyTFwN6vKFKee3pwdY72Pmv930T671i/GmdgR1n6VLufz7Qjb4lha23PLC1niZ5xU2imczS1Jazy0O5GinYKAcT74g7+C7A== Received: from DM3NAM03FT060.eop-NAM03.prod.protection.outlook.com (10.152.82.58) by DM3NAM03HT187.eop-NAM03.prod.protection.outlook.com (10.152.83.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1101.12; Thu, 1 Jun 2017 16:58:09 +0000 Received: from DM3PR18MB0764.namprd18.prod.outlook.com (10.152.82.57) by DM3NAM03FT060.mail.protection.outlook.com (10.152.83.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.12 via Frontend Transport; Thu, 1 Jun 2017 16:58:09 +0000 Received: from DM3PR18MB0764.namprd18.prod.outlook.com ([10.166.163.20]) by DM3PR18MB0764.namprd18.prod.outlook.com ([10.166.163.20]) with mapi id 15.01.1124.020; Thu, 1 Jun 2017 16:58:08 +0000 To: Levi Morrison , internals Thread-Topic: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions Thread-Index: AQHS2W5iuE7e5VDar0K3q/rbmtl0haIQItMC Date: Thu, 1 Jun 2017 16:58:08 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: php.net; dkim=none (message not signed) header.d=none;php.net; dmarc=none action=none header.from=outlook.com; x-incomingtopheadermarker: OriginalChecksum:92CBD3FA0816CFC0767CBD2E2B93BD06080225582FB9DC9034E7788F0DB70577;UpperCasedChecksum:408C3E50DFED679F48A1F0D0DE8C35B2932D7EF308B4E1AF883FB831C5768587;SizeAsReceived:7280;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [9E2LW/Ml2ywlk89SQPXucUWkMA9m4Sxu8feFjKjFJr0=] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM3NAM03HT187;24:5AMfdNoi9P9xIQKwiEB4I+P2NjnIp9DlBl3tWiVaQScovmigHfSgXVVuX/Z5Nu3PPuxAz+NKERQUTFsTXcotcTIY8zQaupfBU0W2g98JdZU=;7:73PTOSqVAQ2BzMNk7c6Ua4ioisfISQ32rSWluiGROlReKaW5sectwJq4sNtOHRNzmfXthMvt2QNQHxHHb7Pgs+zCq4A8Y2SaxTBQDhCX/7tVV//B3Si2YPSvijNyAwGL12jpHDi6I1LBHQ7zI5x3WKeX4P63FW2FSdZW08rmzHwrt0CqgmhsZQ/wsz/DDfCUC5t+rcLruGC25KI/JZXQ2SdTQdsmfXMHxcaAnZ76iyJp6yTteTLnpQppuEPznOYUectw2yezG2QsHNHBlugenmIfMrLvEZQUlHm6hBzjsOgVh3gBhi38+0A5g61g8wJC x-incomingheadercount: 45 x-eopattributedmessage: 0 x-forefront-antispam-report: EFV:NLI;SFV:NSPM;SFS:(7070007)(98901004);DIR:OUT;SFP:1901;SCL:1;SRVR:DM3NAM03HT187;H:DM3PR18MB0764.namprd18.prod.outlook.com;FPR:;SPF:None;LANG:en; x-ms-traffictypediagnostic: DM3NAM03HT187: x-ms-office365-filtering-correlation-id: 89f7da56-238c-4aa3-7d56-08d4a90f6166 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201702061074)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322274)(1601125374)(1603101448)(1701031045);SRVR:DM3NAM03HT187; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(444000031);SRVR:DM3NAM03HT187;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM3NAM03HT187; x-forefront-prvs: 0325F6C77B spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Jun 2017 16:58:08.8386 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3NAM03HT187 Subject: Re: [PHP-DEV] [RFC]Discuss] Syntax for Arrow Functions From: theodorejb@outlook.com (Theodore Brown) On Tuesday, May 30, 2017 at 12:58 PM, Levi Morrison wrote: > Based on the discussion there are a few different syntax choices > people liked. Overall it's a feature that people seem to want but > everyone seems to prefer a different syntax choice. > > 1. fn(params) =3D> expr > 2. function(params) =3D> expr > 3. (params) =3D=3D> expr > 4. (params) =3D> expr > 5. > [](params) =3D> expr // binds no values > [=3D](params) =3D> expr // binds by value > [&](params) =3D> expr // binds by reference As a userland developer, I've been waiting/hoping for short arrow functions for a long time! Option 3 seems like the most obvious choice, since that's the same syntax Hack uses. Would it be very difficult to implement the parser changes necessary for this syntax? Or is there some other downside to a more powerful grammar/parser (e.g. worse performance)? If option 3 isn't viable, my next preference would be option 1. Presumably the drawback of a new symbol is that it might break existing code using `fn` as the name of a class or function. However, using a new symbol would arguably enable more readable code than the other options. Option 2 is not only lengthy, but it also could be confusing since it reuses the `function` symbol for something that isn't a normal function. Option 5 seems overly complex and hard to read. Whether option 1, 2, or 3 is used, to me it seems that capturing by reference would be the most useful and intuitive behavior. It's intuitive since implicit capture makes it feel like all the captured variables are in the same scope.=