Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104641 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39181 invoked from network); 11 Mar 2019 02:26:37 -0000 Received: from unknown (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (40.92.64.35) by pb1.pair.com with SMTP; 11 Mar 2019 02:26:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=htJP1v4actPsWkznM6I3HOFI627iBkV7t86TiDO7YIU=; b=ImJ8DGq9yjlLsUHdJABfguxfI4fBhBmQ/prdqqalhptC6c+Xa8xgTtRskpmALHJo+K0nac08dgF36BtxWZw9+RYlrn8K7YaqoK4jy68cDQzhVv84lHgHlaszV8FC5eX5AyP08efAMXGZCtATW4tN1bNhfpkJQktIw04XDq9TUjTb1yyK7Nej6VW0zeu5x5OeMp1T6EGXU+sS7SIrvWk/jW96PpFXUCVHvOYohV1IqPXLdCUKaJTdSnOJXznTTH6p2lhHzT/T7m8GfHfKmU2Isd6p2HDAAlpXDmT2yeW6r9/ZAXMWBG7yN777Pz+xru21c2EHPy0STbIK3pQ5Sh/SDA== Received: from DB5EUR01FT029.eop-EUR01.prod.protection.outlook.com (10.152.4.53) by DB5EUR01HT050.eop-EUR01.prod.protection.outlook.com (10.152.4.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.19; Sun, 10 Mar 2019 23:16:05 +0000 Received: from VI1PR07MB5357.eurprd07.prod.outlook.com (10.152.4.54) by DB5EUR01FT029.mail.protection.outlook.com (10.152.4.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.19 via Frontend Transport; Sun, 10 Mar 2019 23:16:05 +0000 Received: from VI1PR07MB5357.eurprd07.prod.outlook.com ([fe80::e814:f80a:31bd:4dc3]) by VI1PR07MB5357.eurprd07.prod.outlook.com ([fe80::e814:f80a:31bd:4dc3%6]) with mapi id 15.20.1709.011; Sun, 10 Mar 2019 23:16:05 +0000 To: Larry Garfield CC: "internals@lists.php.net" Thread-Topic: [PHP-DEV] RFC Draft: Comprehensions Thread-Index: AQHU14qlZljCURbb7kSFTt941dIPw6YFf2CA Date: Sun, 10 Mar 2019 23:16:05 +0000 Message-ID: References: In-Reply-To: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR2P264CA0015.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::27) To VI1PR07MB5357.eurprd07.prod.outlook.com (2603:10a6:803:a6::21) x-incomingtopheadermarker: OriginalChecksum:52281EC5F8579736F1EB756E32900D0248F5DF61B3A2B087E27178AA7CF42346;UpperCasedChecksum:662FB6B6B4BC9D789B522F15A13295023E60D8BF82BD08AA55F4408A5833B294;SizeAsReceived:7534;Count:51 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: Apple Mail (2.3445.6.18) x-tmn: [mXS6l6I4n6RqSywZPiuNeCXAeV3njlZ6jJyMtJbBk6Ru1Bo1Om+BxTqmuaxqd5w3] x-microsoft-original-message-id: x-ms-publictraffictype: Email x-incomingheadercount: 51 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(20181119110)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031322404)(2017031323274)(2017031324274)(1601125500)(1603101475)(1701031045);SRVR:DB5EUR01HT050; x-ms-traffictypediagnostic: DB5EUR01HT050: x-microsoft-antispam-message-info: zymXQMPZnnaFyOevrE2Xxtde+gPaxcUaJ9lUjO1qusrLPka2dfw95jL+GBxG3NAW Content-Type: text/plain; charset="us-ascii" Content-ID: <657E8F96B40CD84B910325C0525355D8@eurprd07.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 45e059b6-f1ca-4a21-da1c-08d6a5ae5ea0 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Mar 2019 23:16:05.7571 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR01HT050 Subject: Re: [PHP-DEV] RFC Draft: Comprehensions From: bobwei9@hotmail.com (Bob Weinand) > Am 10.03.2019 um 22:44 schrieb Larry Garfield : >=20 > Hello, peoples. I know it's been discussed once or twice before on the l= ist, many years ago, but not recently. I therefore feel OK putting forth t= he following draft proposal for Comprehensions, aka "compact generators", i= n PHP: >=20 > https://wiki.php.net/rfc/comprehensions >=20 > Sara Golemon has written a preliminary patch that is partially complete (= see the RFC link for details, it's impressively simple), but unfortunately = doesn't have the bandwidth to complete it at this time. I am therefore loo= king for collaborators with more knowledge of internals than I (which is al= most everyone) to help finish it up. >=20 > The syntax proposed is also subject to revision if a terser but still lex= er-friendly alternative can be proposed. >=20 > At the moment I'm not calling this Proposed yet, as I don't feel comforta= ble doing so until someone else is on board to finish coding it. That said= , if someone wants to weigh in on the concept for now (hopefully supportive= ly) that's also fine. >=20 > Anyone excited enough to help finish the job? >=20 > (This is my first RFC collaboration, so if you're going to smack me for g= oofing something please be gentle about it.) >=20 > --=20 > Larry Garfield > larry@garfieldtech.com Hey Larry, First, I like it. (the idea/intention behind of providing a compact way for= list comprehensions) Though in general, I think this would be better off implemented with a more= flexible short closure; it feels like a special case of these. I.e. that t= he comprehension syntax can be simply desugared to an immediately invoked s= hort closure. At that point also, it can be a compiler only patch, if we ha= ve short closures with the appropriate binding behavior. I guess it should be pretty easy to build that on top of my existing short = closures patch. Regarding the syntax, I'd not conflate for with foreach, the distinction is= built into PHP and as such should remain. We also might have trivial argument-less short closures written as "{ stmt = }" simply, having the comprehension written as $gen =3D {foreach($list as $= x) if($x % 2) yield $x * 2;}(); (note the trailing "()" function call - if = we desire to, we might make the semicolon at the end of that single-stateme= nt closure optional.) Bob=