Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119450 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79384 invoked from network); 1 Feb 2023 22:35:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Feb 2023 22:35:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7C363180507 for ; Wed, 1 Feb 2023 14:35:13 -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,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.104.0.0/14 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) (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 ; Wed, 1 Feb 2023 14:35:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OKCGbOhIgxbfzsx9d2QQzX265xnaqkhSOzl2/iyUV4AjFxZrqfbvJF+wtCbNy2n13mXrhE9856a2HRzokd+1wa8uCCvbnBhF2ixp+bLNbR/Pt8bYL87U09ESLINiHRCHfuVCcVZ4XPW0YLdFkDiodTPukaVyXfLBstzYs+aBNVRL0N9wBMJNmjsisB6LHZG9oBm+lmHGhskrQTBXd13pimK/RQxxC7hhTOWUKzystPwy9pwiB7gXZIlif2XMgteQIQrWCo8fWKKXA+CMBSrpDgrvq6evA2Ey0klWnnqGYugns3McUsX+tzZbfyi4da/I4NKs45o39fmiIxesH0OP3Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VJTa6PO1tkvL4YKXT7QFFYkwIBPRhzwrGWF3rAS65WM=; b=Mb6U86f5qbKxqlnoP8K0hRGRf/WUbVBKhG0LizRu+m+DOG3eP4G+whVw68XIB0CA83zBPguOlCjV4kDiELPjM64hcF+QeqSlH6WuZRl5VDUUpkeW1uJT00JGaIx12jGY0G+r6tZY+bxtjbUZ6mQgJnKKmNuTMfTTQXrJuZQcW5NdseFBVC8i+evLlhV3Cv1kvEuIvgN9jdM8oYtl8dZA23W5PpFiEqTLOp1pMGTePr6rBNlIcrSdJaZKJeqLN1q7o9+WfAltoZ1AN2hHU6UmOIlyMHe/5v632R0y+sRJXceGGGR3JqhvVx12ETYZJoBqCDuEfnPbv+D0dmGJqipJyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=shymko.net; dmarc=pass action=none header.from=shymko.net; dkim=pass header.d=shymko.net; arc=none Received: from PH8PR10MB6337.namprd10.prod.outlook.com (2603:10b6:510:1cc::10) by BN0PR10MB5304.namprd10.prod.outlook.com (2603:10b6:408:129::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25; Wed, 1 Feb 2023 22:35:07 +0000 Received: from PH8PR10MB6337.namprd10.prod.outlook.com ([fe80::ed95:e287:42b3:6a2d]) by PH8PR10MB6337.namprd10.prod.outlook.com ([fe80::ed95:e287:42b3:6a2d%7]) with mapi id 15.20.6064.017; Wed, 1 Feb 2023 22:35:07 +0000 To: Kamil Tekiela , PHP internals Thread-Topic: [PHP-DEV] RFC proposal: function array_filter_list() to avoid subtle bugs/workarounds Thread-Index: AQHZNmE0J1j9kkHlVEGnXGJGbZE+rK66V7aAgAACEMaAABaBgIAAESGAgAAljrc= Date: Wed, 1 Feb 2023 22:35:07 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=shymko.net; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH8PR10MB6337:EE_|BN0PR10MB5304:EE_ x-ms-office365-filtering-correlation-id: 5ad10e8a-18d0-4b5d-9899-08db04a491fb x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vIZd0j5rn9WKOsIyjhf4WFQ8OdAKFkoWy2EALUlpBBnDIB5+l4yBWKS1t+mx2i7UTNHauwi42jNZhggnIZOTJ/puxqAUkNh0cJaFpVpA1c079gHon2GszKtf+ipkMqIp/Z09E3b6gOxr1co+0oxKsem6Gp69QOV/ESSkqhmDoORmj2nbSoEnF9mTWkx4Cdl0tt6tJC3NulhyHEu0OXafBMJILLqm4PiKY3vwjRKQaZWPnVrscPum1RVf9Tv+OklXjThu6hhgN3S1mn4GK6HbWWoIcxmcRN/o6Ioo5dghgieZ47XzPHBxrWHXM/U2MT76Iv4HlxOd3JFXnPGChuq6JyFzOqjCXLhbEUXR8mdgrI/B+bSCTYjOVrGy4PW9j7lUrGG3A70XMiwa9shSznTOOzuS8V9JpTww+gG0kajJTDXZs9qmYTAoLfTAr1eNg7d8MZNecNiX5suBWmbpRmPuYBA4bsL2NpROZZbcEu90ptx1L9hyCZ8em7keYyuwJAsUC5puAini/bKPUE6AOwlusmwVJRWloLrLkuIdRArriX6h2IDbBzSsRneC1Ab+57xsBecvEy3YvFpEMfufkSFQJHCGxIKKJGIewG/7snAEHpPQsjU8ljnoN/fSYJxYqnki3YR6rHgf+qzSaA3+K57UjI3XpbKqr+pBytdTO6Dz8z0/PzzXelgvzQ0mNrYtHfc94yOJGlI+JPnxMfBwc296UtklhM37fkUFAqeOd55HYzI= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH8PR10MB6337.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(346002)(376002)(39830400003)(366004)(136003)(396003)(451199018)(2906002)(33656002)(110136005)(316002)(83380400001)(71200400001)(478600001)(186003)(966005)(7696005)(9686003)(66476007)(91956017)(6506007)(76116006)(66556008)(66946007)(8676002)(53546011)(38070700005)(8936002)(5660300002)(86362001)(55016003)(52536014)(41300700001)(66446008)(64756008)(166002)(38100700002)(66899018)(122000001)(19627405001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?FNjYtG9gz8wA2hZgt08N3WFydtmgQOiU0QDZt8Y+93kAg//F2+YS0lfrCg?= =?iso-8859-1?Q?Qiv1v7nlxLgwD5Ddlkmn93JGm0K07A9YJFGnVUmLpzZIriO4yF0G58KvEc?= =?iso-8859-1?Q?lYspOa7R+lT8zpeU4Y2t4hNwfqlTc+kw+6ntUa1876+JaXR5LMKwI18PIp?= =?iso-8859-1?Q?ihnJsTs1p55jMxSQrIdFIslN02zaep8R47GQ1+eARi+BKVkqZFebu2OQ9U?= =?iso-8859-1?Q?zaEbIanqlkci4PcfHGsbcyrydasfNk0CNYBCrC0Mxw1/V3BBcAHIR8lFAO?= =?iso-8859-1?Q?7XOiPzasqNqRIAotIaH4K996fy8rVLU/wwE1aQGDzhWFxwTsSobv495Z08?= =?iso-8859-1?Q?veAdNg947r3iGk5g868tbGDVdEMD9bLyy/cErpOcVrMDbNWcU3yFgHKJ3u?= =?iso-8859-1?Q?B3itIdFgburLsBmtqC2xOWEQGsJgkzQBXfBKCFHY1yP0o1IqGFZ4X+4Cwp?= =?iso-8859-1?Q?g4q/IVIvg9vsWd2kGsge6LUeIoDVXTS1T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d4UiXJ3JVAY1uiSOMjdTBbup9/JcQavFMWhBEN9R6mbwLGu32OBtI?= =?iso-8859-1?Q?JrQizYwRCqRIb90S/4bbaRRXowUn5fs1lwEoykmPHQLeDQNzUy9ywKMsuk?= =?iso-8859-1?Q?mTvJAhmiuo/kVdTw99Reer3Yum5nhYh4tNOkrAiP+0SGpeuZTUKTRhfIR9?= =?iso-8859-1?Q?TZlBuqpl7ZS78Oz8TmI09orXJNTIIjdotB3Y09XVbFPrBJc86dAbZJNIoQ?= =?iso-8859-1?Q?ZBVdhiiHwoBuWD1gMnYJsbV6WSV+ymc9mkBTVvdPbHm6w5jD5uJhGWj0Zm?= =?iso-8859-1?Q?YwvT0pau+l5IaEOevxs=3D?= Content-Type: multipart/alternative; boundary="_000_PH8PR10MB633750E25A6E59A47925B637BFD19PH8PR10MB6337namp_" MIME-Version: 1.0 X-OriginatorOrg: shymko.net X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH8PR10MB6337.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ad10e8a-18d0-4b5d-9899-08db04a491fb X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Feb 2023 22:35:07.2921 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d7878c48-41c7-48dd-bd7e-899af7355b7e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iMMtopXU+Q4XZcGRKUinU9Ej8NGNXqeUEQSauA1qjiL6vUt+IA4n+fl+6MZ3IdoBa5bdqLbIWdBjhk0nJQ0Nnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5304 Subject: Re: [PHP-DEV] RFC proposal: function array_filter_list() to avoid subtle bugs/workarounds From: sergey@shymko.net (Sergii Shymko) --_000_PH8PR10MB633750E25A6E59A47925B637BFD19PH8PR10MB6337namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ________________________________ From: Kamil Tekiela Sent: Wednesday, February 1, 2023 11:55 AM To: Sergii Shymko ; PHP internals Subject: Re: [PHP-DEV] RFC proposal: function array_filter_list() to avoid = subtle bugs/workarounds Hi Sergii, First of all, let me say that I am glad more people are willing to give bac= k to the PHP language. I'm happy you decided to join the ML. However, the change you are proposing is unlikely to be well-received. PHP = already has too many functions. It is known as a kitchen sink[1]. I don't think we need list-variants of the array functions. As you noted yo= urself, it can be simply implemented with array_values(). If we do this one= then next someone will say what about array_diff() with a list? Most of the functionality can be implemented in userland and it's usually t= he preferred way. If we are going to add a new function to PHP, it must hav= e a very good reason to be implemented in C. array_is_list() had a very goo= d explanation: performance. Ideally, we would have a separate type for List, but... it can easily be im= plemented in userland so we are back to square one. While PHP's arrays are = something of a Frankenstein's monster, they work well as an internal implem= entation detail of other data structures. Adding more array_* functions is something that many of us would want to av= oid. Regards, Kamil [1]: https://web.archive.org/web/20181107125816/http://www.mcguirehimself.= com/?p=3D117 Hi Kamil, Thanks for your thoughtful feedback! The argument about list-flavored versions of other array_* functions is a v= ery strong argument. I'm glad you're bringing it up, because that aspect worries me a lot as wel= l. Array functions producing a subset of a list are all logically expected to = return a list. I think, this assumption is only applicable to array_filter(), array_[u]dif= f(), and array_[u]intersect(). These are basically all array functions that already have an array_*_assoc(= ) version. Since we already distinguish assoc arrays, doing the same for lists seems p= retty reasonable. You're right, we can totally anticipate people requesting array_diff_list()= and array_intersect_list(). I've got mixed feelings about that, also not a fan of multiplying the numbe= r of array functions. In practice, I've only encountered the need for array_filter_list(), but no= t others. Filtering is different from other functions as it operates on a single arra= y instead of multiple arrays. Maybe it's a sufficient reason to treat it separately from other array func= tions, maybe not. --_000_PH8PR10MB633750E25A6E59A47925B637BFD19PH8PR10MB6337namp_--