Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128215 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id E19331A00BC for ; Thu, 24 Jul 2025 14:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753365812; bh=1B2xUj0o9p8zDvvGN13I0u9tbfdlu1BAdHEx7NzOBR4=; h=Date:From:To:In-Reply-To:References:Subject:From; b=B68IKNWPPXcIq7/MBIDrCcCr8a3YVV2WsQ1VkiHTumvzmGBl1OeDmVGxrTclxWS1K YwdsgzqVhh+r5z6yMrHruUNlrOgGR3/XLKCgW45kXIhP7s5b7/G/NRJ1g1A8VEujOU pOWMLcrO8eTgLv8SyfidIdhYVvq6/ZFCHddK2O6XOyhQyIs5/GAzsj0xg8p6vhgUGW uB+MniGZKuLy5goLaE6eYvSVqZkdOJBGMei1r0xSkDX1jAKtfMv1Ne/bFf7L0ovCGF /VLy/g+tyQpWL9H9bszQlq51RKi5hgIrUnw+fdrofn06rJvvn/2HiafpKUndvbbdMF eyWrdAlBiroYg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BEAEC1801EA for ; Thu, 24 Jul 2025 14:03:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 24 Jul 2025 14:03:30 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id A9C857A0255 for ; Thu, 24 Jul 2025 10:05:14 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Thu, 24 Jul 2025 10:05:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1753365914; x=1753452314; bh=8KzNQswL28xACViIQCpy4 oznrWWe1i2DfACxnsWLBYw=; b=JArMObOFYi4ddNjtSlIrgXZGO5BPpVm0+Vxjn yYqhlZflXJSeLGEqiURTyyhZaqpnfcipzajedm4HOhluDBfXphllkCAIbGMADsyT 9RGZGNzYDwifASVy8PbLJshT7U/LvUvEHefLgYogMZAKf/epEtSQZL2zCRASdNBT 6eSuGY7kFHI295LfbKVzTXk80q+mrS0Wbn04ZchnOI3pmu7/gRlPa8zuivDdmb/j g9F/a8eQ0m6UYmjzTpfYHyBvu/DEldPVN0VKzDZwhknKZcmCbZQjXjQrapPpjek3 ioyEEo8HuqWLaA6k4tj73jD/JUL+j3SmEntIe7tDyCG8Dem2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1753365914; x=1753452314; bh=8 KzNQswL28xACViIQCpy4oznrWWe1i2DfACxnsWLBYw=; b=ngaffIgnTiOE6ydVB xOJ520pMA7TUb9dpsui5d1e4a9MBJoBpd/Tk3URB+VMBmLjD8HpKEINtiHnxsDCd ERuNi9Iw5Sq3RDC2cZoTdNGNPMQXZIO8zO0EROtOhEUDcjwdTRI6fUuKyfKF5gXt OsUsoz1LBDqtOsW9UzJ2uYK8Yu+fOwlJqwHaK+NbZRxmBcv2CyRVypFM1QpNMZHp c2BkTAxI8839wbBZl8XypZDcliiWGW+WeLoOfy//Qz9EfFCOHOUitdnfsYfHVceG Man6hsnp3LfMiJ3UWd47uv6aih0PBzpcGZ9+lz/amdnPxX5X7QNtlkVOVOct1fJt vZhRw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdektdekgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtqhertdertdejnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepheejfeevgfefudetffffvdehiedukeeifeelvedvudeigfek hedvveehffdvgeetnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhi vghlughtvggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 36646700069; Thu, 24 Jul 2025 10:05:14 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T7b7d29473ae5162b Date: Thu, 24 Jul 2025 09:04:40 -0500 To: "php internals" Message-ID: <779a8062-72d7-405a-b15c-136c8e971f7f@app.fastmail.com> In-Reply-To: References: <52dbe5236df460958644677c781513c3@bastelstu.be> <395ee57ca13b16ab09301f9bee6f07b9@bastelstu.be> Subject: Re: [PHP-DEV] [RFC] Partial Function Application v2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jul 24, 2025, at 6:52 AM, Tim D=C3=BCsterhus wrote: > Hi > > Am 2025-07-24 12:03, schrieb Tim D=C3=BCsterhus: >> I don't think they should. Specifically the (1) and (3) should not. M= y=20 >> expectation is that: >>=20 >> $f =3D foo(a: ?, b: 2, c: ?); >> $f(1, 3); // calls foo(1, 2, 3); >>=20 >> and >>=20 >> $f =3D foo(c: ?, b: 2, a: ?); >> $f(1, 3); // calls foo(3, 2, 1); >>=20 >> The order of the question marks should match the order of the=20 >> parameters in the resulting Closure, which is not necessarily the ord= er=20 >> of the order parameters of the original function. That would be inconsistent with how named arguments work anywhere else. = With a regular function call, you can list named args in any order you = feel like and the engine will reorder them for you back to the original = defined order. (My IDE keeps yelling at me to put them in order, but th= at's an IDE problem, not a language problem.) Having PFA behave differe= ntly feels needlessly confusing, especially since positional placeholder= s are supported, too. $f =3D foo(?, a: ?, b: ?) It's not obvious to me what should happen there. Does that implicitly m= ean $c is now the first argument? That's not at all apparent from the s= yntax. Similarly, in a longer example:=20 foo ($a, $b, $c, $d, $e, $f); $f =3D foo(?, 3, b: ?, e: ?, ...); That already takes a moment of thought to know what's going on, despite = being legal. (A value is provided for $c, but nothing else.) Having th= at also change the order to... I think it would be f($a, $b, $e, $d, $f)= ? Just raises the effort to grok it even further. The only value to breaking existing convention and reordering parameters= I can see would be: > To add to that: By respecting the order of question marks as written, = it=20 > would also make PFA easier to understand and also more powerful. After=20 > sending the email earlier, I came across this doctrine/collections PR,=20 > while reviewing some dependency upgrades:=20 > https://github.com/doctrine/collections/pull/424 > > When migrating the `findFirst()` method from a custom foreach loop to=20 > `array_find()`, they couldn't pass along the given callable directly,=20 > since Doctrine opted for a different parameter order. Thus they needed=20 > an intermediate Closure to swap the arguments. If the argument names f= or=20 > the function are known (which they are not in the Doctrine example, as=20 > it's an arbitrary Closure that is given), this would allow to swap=20 > arguments as necessary: > > function cb($key, $val) { =E2=80=A6 } > > array_find($array, cb(val: ?, key: ?)); // array_find expects=20 > $value, $key. Which is valid, but on balance I think it's OK for that case to still be= a manual short-closure in exchange for less confusing behavior of PFA. = In practice, I expect most PFA uses to be creating unary function anywa= y, followed by thunks, so it won't greatly matter. Does anyone else agree/disagree? --Larry Garfield