Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116584 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59716 invoked from network); 7 Dec 2021 16:33:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Dec 2021 16:33:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B4AFF1804DF for ; Tue, 7 Dec 2021 09:34:11 -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=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 7 Dec 2021 09:34:11 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id CB8E95C025B for ; Tue, 7 Dec 2021 12:34:09 -0500 (EST) Received: from imap43 ([10.202.2.93]) by compute6.internal (MEProxy); Tue, 07 Dec 2021 12:34:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=gQunog Sl5UxNClix8nG7fDPnhmGgLzJpsBSCSofe73I=; b=HKEF4tHBN7hq9ib+JsHji+ ybFprugLcQHa0yRAGLTRsI54lfnv6BwbLgxpsqdPdQyXgzYdHaIsfK6dhHsVuIrD o7mLO5ZspVUVFlh08IqxavCeh8nG3oMKHTWAENKdSKnhBJ+ySKrWG7UFtsvlfFQI 9B1z+uh5IxZ83r68ZLxS40Oc+viD+wXSCSMQnC5umINamXrlVlBn8GE5Gsi2ESao TApKd4v1zoNYUOoVX5aQF+yDKBg0ew2nMs0R3DAVRRsZFOylKqv5mgBaisadIH0w X0TzMBTBtkpBlPAyqqC/zNvvs2O0a0Pocv0Kon8BlVewYEKe9vGRXS/rrP6+Txhw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrjeehgddutdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpedvgfekgfduhffhjeeufeefgffhgfejvefgfeekkeek hfeluefgteejheekgefhveenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhphhhprd hnvghtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep lhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8EFA2AC0DD1; Tue, 7 Dec 2021 12:34:09 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4492-g121c2470aa-fm-20211206.001-g121c2470 Mime-Version: 1.0 Message-ID: <1b5790ec-1ffb-461e-b3fc-91d59a6db831@www.fastmail.com> In-Reply-To: References: <61ac9759.1c69fb81.b0241.1e6fSMTPIN_ADDED_MISSING@mx.google.com> <268F5B4F-4770-48AA-B212-DE23116BCF4C@gmail.com> <2e4dd298-77a1-4c40-ba31-1c9b7ebe1bb1@www.fastmail.com> Date: Tue, 07 Dec 2021 11:33:48 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] RFC [Discussion] array_column results grouping From: larry@garfieldtech.com ("Larry Garfield") On Tue, Dec 7, 2021, at 3:42 AM, Hassan Ahmed wrote: > This is a great suggestion Hendra, I really believe that it may take > the new function to another level, but - with Larry's comment in mind > - this is a language design more than function design. Supporting the > list/array comprehensions will be a great step for PHP, as I can > remember that Nikita already implemented something like this > https://github.com/nikic/scalar_objects as a workaround but I am not > sure why does this was not implemented in the core yet. Almost all of > the array_* family functions - including array_column - can be > achieved by a `foreach` call. so I do not believe that we need to > decline the new function and maybe in the future, we can add more of > your suggestions for it. especially the `map` parameter which IMHO is > a promising addition, it can be a mixed argument [ string, array, > callable ]. BTW your thoughts led me to change the order of the > arguments for the new function to be `array_group($array, $index, > $columns)` I will update the RFC with this. And if you want to map, reduce, or filter without grouping? Then you can't really use this function. And as noted, the order in which you apply those operations may matter, and no order is necessarily more obvious or beneficial. Either of these approaches would be superior to cramming more functionality into a single-purpose function to turn it into a single-function swiss army knife: https://wiki.php.net/rfc/comprehensions https://wiki.php.net/rfc/pipe-operator-v2 Swiss-army-knife functions are a design flaw. Robust primitives that compose nicely are superior in nearly every way. --Larry Garfield