Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112583 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33286 invoked from network); 22 Dec 2020 01:15:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Dec 2020 01:15:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 45C851804DD for ; Mon, 21 Dec 2020 16:48:03 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10olkn2098.outbound.protection.outlook.com [40.92.41.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 21 Dec 2020 16:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j2bvO0bWGJModiqiSkqIIWvo/tPMqIinWVDuYy0xR6bwA1s4sa+bfTWAXffbcFDXmFjkPLfi4ZVwJm+vJ6/xwW0/+nZ9d6Ljf23XIIpTZkNIHt6xFODRanFjLLX0K7YetuPqDIcDWmaZWsqXNYghd88+Ay1EYDRvatjt8voTAbyiW38VJqWY71Oz6y44TDtPJXD3OXbKU8ILzIPv81Aruo6EhChYO2XgHu3ob0/TLhTonG0B9mNKa1gQ2dRXYugWvYxlXQRtiCtjk/FrfyferrNryhBJd3PJ5U31ohzaBHUClHmAXDhktA6Ib/mixYR5JJXwhgqLRAiR8mV9BUn1wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=65EwfJBPOGnrs+c2XEcMEEkax+nDXI5JmSoSbBEVRYY=; b=KwVEJET+wLF35UqEIOT51KtMWDeTJdpxCnfGFpP+tcVD1CCJ7u8L/jXUTgW3N5zsY6Vi+tS8RH3erJscalLXOsSLkeNk8/5TzZJKTo8ms1HvpuDQ+dFzv//EGfhg4lmbUIo2QhnmX2DmSOKEweVDjPhN6dl5ZtxBb734Halu2mSY8a2DBfqC/PPGxWIWOLYss3/3mDnfZgbgCySOob1Qa/WqdS5WhTFTZ1MkT/Aq+iJ6EjR93aAmb5G5W12UFcwiUpOWLfYlU+UYFVNRf9XaEUOKysAcX58P0m3k4BazCdSgRgxK0mowDIcc5xb0J9a7ag1QKedq79Bed30tpTie7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none 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=65EwfJBPOGnrs+c2XEcMEEkax+nDXI5JmSoSbBEVRYY=; b=rF0mU0wnZtGyXm1owZUKk/fFidjtGWl4ocqbStSiBYoOgdCkEe0YAdkFdSexBJGGBMwz5Xi+YmKiva2VuvPVKR7ZnpqIZraFuBsa7m+LMfmlhwS747ySe6njfSd/ueIYH8zvCrZP7YBTDWqMDMAEIyGJiXpVobbeqV+eoOnfmzkYx0NIML92PNXJrW7ijadnmcjWMl0emOioCc7+lGBlp3mCsCLUUOFLzcZJj9Qk1V5LeoBGKyy6vcH7uP0/LlR+YXmzzyei2OfMGfkzHr8lMN/TQnLRzIFXK7LapaXWARpeaFLzqzk70aaS5N78MCn9Ri1ac9EcQqQTdm+TLTCmEw== Received: from MW2NAM10FT050.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::51) by MW2NAM10HT093.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::434) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.22; Tue, 22 Dec 2020 00:48:01 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e87::4b) by MW2NAM10FT050.mail.protection.outlook.com (2a01:111:e400:7e87::269) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.22 via Frontend Transport; Tue, 22 Dec 2020 00:48:01 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d%4]) with mapi id 15.20.3676.033; Tue, 22 Dec 2020 00:48:01 +0000 To: Sara Golemon CC: "internals@lists.php.net" Thread-Topic: [PHP-DEV] Straw poll: Naming for `*any()` and `*all()` on iterables Thread-Index: AQHW1kOROymHHd+jAEaQQL1oN/KEl6oB0/yAgAB0iVY= Date: Tue, 22 Dec 2020 00:48:01 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:29A30CD12449B40044AF3F25A745E7879A402639D2422C32D530F60874FC87E9;UpperCasedChecksum:E56EDB06D4859FD80779055B245745D3340B5139B41C3681424FB7F3C83BA055;SizeAsReceived:7202;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [bNbATlmanmxFMd6mkzwEHTBsGPyg1sUQxq0l73tX8THPg4srh8qrcWpDI/N9xN5h] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 29557e0d-7cec-4088-dbe1-08d8a6133c00 x-ms-traffictypediagnostic: MW2NAM10HT093: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: UUsQ6COEAgs07vO8+cmutac8NxIQnoM0HAzd+lhu69azFKLfdwZmi1/L5k6o+uBmZJFk9LVRjXIFaVDRI2Ho2E3ylJS6yF5CA+cYXllMqqnaXuqKiKt+UdVUmQgMsZs1uYsVbtyWsH1qBB7e9mi3ibpMf+LZNNNxfhZ6MpzljOSkE5jAtWJEvVhkR2cx1fXOPLIms2c3XRc9PuphVSbkgYDnheYDlPGp8cwA1bStRpFbFZdgAfvf4fg/WKZmuGEJRhY0niUgN5+Xfirm5gth+zRENbBVxJZf+XHKNDcjjIk= x-ms-exchange-antispam-messagedata: dQZs6W+WDaXomsv0dlczbtaOoOicm0F+BSNo33mpLngcWkUKz0F4BNxCw9UUPTUlg0pQd+idUAS9xbIPpplB9nXVWegXWndpY5VL05Ojwk/LkDK9My7iNYCfjPYDlvzWlkggCkeg6SB2smxmH6yE/6J+f87uPfE5v3w9hKvnQPOqNYk0kI/LzW2ovhrk+XxjX1FTI/5Sv63hVklxnUhjvA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: MW2NAM10FT050.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 29557e0d-7cec-4088-dbe1-08d8a6133c00 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Dec 2020 00:48:01.3404 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM10HT093 Subject: Re: [PHP-DEV] Straw poll: Naming for `*any()` and `*all()` on iterables From: tysonandre775@hotmail.com (tyson andre) Hi Sara Golemon,=0A= =0A= > This is probably going to be a terrible idea because it involves a little= magic but...=0A= >=0A= > "iterable" is already a forbidden userspace class name since it's reserve= d for the psuedo-type=A0which is a union of `Traversable | array`.=0A= >=0A= > What if we went ahead and defined an actual (abstract-final) `iterable` c= lass.=A0 The parser rules which treat `iterable` as a special type still ap= ply, so we never try to match instances of class `iterable`, but what we ca= n do is define methods on it.=0A= >=0A= > class Iterable {=0A= >=A0 =A0 static public function any(iterable $iter, Callable $predicate): b= ool { ... }=0A= >=A0 =A0 static public function all(iterable $iter, Callable $predicate): b= ool { ... }=0A= > }=0A= >=0A= > Then the API is both 100% searchable (the man page for iterable can expla= in that it's a pseudo-type AND that it has helper methods), and intuitive t= o read/write.=0A= >=0A= > if (iterable::any($iter, fn($elem) =3D> $elem =3D=3D=3D 'foo')) {=0A= >=0A= > }=0A= =0A= My objections to that are:=0A= =0A= 1. As mentioned in https://wiki.php.net/rfc/any_all_on_iterable_straw_poll#= rejected_choices , I'd objected to static methods in general because it wou= ld be inconvenient to polyfill=0A= (magic such as __callStatic or disable_classes might be possible but in= convenient and integrate poorly with IDEs/analyzers)=0A= =0A= (if more than 2/3rs of php developers are in favor of more comprehensiv= e functionality later on, such as none(), first(), etc.)=0A= 2. The name `iterable::any` would make it impossible to polyfill iterable::= any()/all() in php 8.0 without using PECLS that modify the internals of php= in unsafe ways (class_alias also forbids 'iterable' as an alias). I'd stil= l prefer IterUtils/IterableUtils:: over iterable::.=0A= 3. For these reasons, I assume static methods have been fairly unpopular on= functionality not associated with an object instance, but the main reason = may be something else.=0A= =0A= Also, on an off-topic note, `abstract final` is forbidden for userland clas= ses, so making it have those flags would be surprising for uses of Reflecti= on such as code stub generators,=0A= but forbidding the constructor would be close enough.=0A= Although I think `abstract final` should be allowed like it is in java,=0A= I think RFCs that proposed allowing `abstract final` failed by a large marg= in years ago and I don't plan to reopen that.=0A= =0A= Thanks,=0A= - Tyson=