Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128191 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 600BF1A00BC for ; Wed, 23 Jul 2025 13:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753278862; bh=oVkzJh2BRzASov+2unsoAdb6MDr1MJNHTOxcK5psxww=; h=Date:From:To:In-Reply-To:References:Subject:From; b=XMBjL7qD4tWJHOpRQnyC3MIpmq5FlddHTTVbpapcgYc67AiuKofIWib/JVpDSHJ2v K+8R3ioqtsU5LsLemY1XjUF4PslmGchnm5OJWddX90c1sf19VioWxbbENW3ss9jzP6 vUKMzwVHQ3WKGo50nyzinyx0eT8wTXi+EPatr5gBBwc/NF8QdmSDcDO+yUPcjc+GYT a9oRDGqzIrUV+fatKnQzPpL6qkbIYwrZaSs17e2G75S/ijVyF9liQcYxpNBS7K6QUb vZ8JySaXfEPkYwWNf3EV7R+Cvyjh5aXeUlyCdKstmuXCZ8tf3D4sF0NCJvlKCK0dGN NCEBsyvu1Ebcw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EFD7E18004E for ; Wed, 23 Jul 2025 13:54:18 +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 fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 23 Jul 2025 13:54:18 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 13516EC1FFA for ; Wed, 23 Jul 2025 09:56:03 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Wed, 23 Jul 2025 09:56:03 -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=1753278963; x=1753365363; bh=FNS6Dmh9x+HS30kstJff2 vZCFglCIV/fFlHmGW3nYTI=; b=n5MZmpSSqF1/bXZn+PUWb8+Xk6rRnB33r4AXD ASq/IJqO+cMXUnCb25lM/0e8uCKoJCKkdPTmIS+hRh6YioiuzU4iSn83nTi3uPDW evCi3hg4RdsezR4lEHYc8alACZZxfrTbGor73Oc+Mz0igD1kSp9ElGmOlGtiXIcL YIoiVAtiA9OsFlK9dkpmgDVfKirOLWEYL7wLcu2fWfzS1yHiKyIjHCPD5HxqzsTP 1YYDf2xJXpbavHgZHlgPw2onxaFr2R5ao0V337SqKlvqmyhvoUr53UHjLQ4LXBMH +QYIt0H8iY1qyDs4EpY304vsKfpG375GGRL7Sz4iSYt/emGCQ== 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=1753278963; x=1753365363; bh=F NS6Dmh9x+HS30kstJff2vZCFglCIV/fFlHmGW3nYTI=; b=eduAnTpz++oeZ8GEz QHeaxcouMQaM/SOREiN5iy8WCvxra4LVLHZzrN3Ib+GKL0swrXTTUAgWG+grRb8G YKbrxPrVI3qWqHd57V365OiR0JoV8tKhG4CJ9icoB0lMBI47Vqj/Cc5CWa56S0Mz /y4jJANnJ+7XuHK8vQ/+GZlryGDu4efVbxX+/4teKLLGeRzjw4XHez1wTrCUpaaA jsWcL7Gjhqn3QF8fiJrYaJDV/gxVli/yBAhiElnvu0qRN71a2TYhSjSSCGDYJ/1N k4PYByzKjRJPG8FrxWN8aVi4LNLHVy130d3Rb4eftc4bCwAwhzgA39yynPebvZXd QD3+w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdejjeelhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtqhertdertdejnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepuefgteeijeeuveffudelhffhtefhkeevtdeuvefgffdvfeei vdetgfehveetleffnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhgu thgvtghhrdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprh gtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 8840B700065; Wed, 23 Jul 2025 09:56:02 -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: Wed, 23 Jul 2025 08:55:41 -0500 To: "php internals" Message-ID: In-Reply-To: <52dbe5236df460958644677c781513c3@bastelstu.be> References: <52dbe5236df460958644677c781513c3@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 Wed, Jul 23, 2025, at 3:56 AM, Tim D=C3=BCsterhus wrote: > Hi > > Am 2025-06-28 07:06, schrieb Larry Garfield: >> https://wiki.php.net/rfc/partial_function_application_v2 > > I've now given the RFC an in-depth read. I have the following remarks: > > 1. > >> If the function is variadic, there are two additional rules: >>=20 >> - Any positional placeholders that run into the variadic portion beco= me=20 >> required. >> - If any positional placeholders run into the variadic portion, all=20 >> prior remaining placeholders become required. However, those paramete= rs=20 >> may not be called with named arguments, as there is no name to use. > > I do not understand what =E2=80=9Crunning into the variadic portion=E2= =80=9D means. An=20 > example would probably be helpful. The first bullet point is probably=20 > intended to mean the following: > > function foo($a, ...$b) { } > $pfa =3D foo(?, ?, ?, ?); > > Now `$pfa` has 4 required parameters, despite `foo()` only having 1? > > But I don't understand what the second bullet point is intended to say. I have added the following example: function foo(int $a =3D 5, int $b =3D 1, string ...$c) { } $pfa =3D foo(?, ?, ?, ?); // Equivalent to this: // Note that $a and $b become required, because there must be at least 4= arguments. $pfa =3D fn(int $a, int $b, string $c1, string $c2) =3D> foo($a, $b, $c1= , $c2); > 2. > > In the placeholder semantics section: > >> While in theory that means a call like this would be legal: > > From what I see this specific case is not part of the examples sectio= n=20 > either. Including the desugaring of this extreme case would certainly=20 > help understanding. I have added the following equivalent: $c =3D fn(string $s, Point $p, int $m =3D 0) =3D> stuff(1, $s, 3.14, $m); > 3. > > In the =E2=80=9CExamples=E2=80=9D section: > > The choice of parameters names makes it hard to understand the example= s,=20 > particularly when named parameters are used to provide arguments out o= f=20 > order. Including the =E2=80=9Cposition=E2=80=9D in the name of the par= ameter would make=20 > it easier to follow the example, since it is not necessary to look up=20 > the signature of `stuff()` all the time. (it becomes manageable if you=20 > read it as a sentence "is FPM") LOL. That was completely unintentional. :-) However, I have gone through and added numbers to the variable names to = clarify their original ordering. > 4. > > In the =E2=80=9CExamples=E2=80=9D section: > > Is the =E2=80=9Cthunk=E2=80=9D example accurate? It's the only example= where the=20 > resulting =E2=80=9CPFA=E2=80=9D includes a variadic picking up the rem= aining arguments. Hm. I think you're right, with the Extraneous Args section's clarificat= ion, the others should likely have a trailing ...$args as well. I will = clarify with Arnaud when he returns and update accordingly. > 5. > > In the =E2=80=9CExamples=E2=80=9D section: > >> $c =3D stuff(?, p: $point, f: ?, s: ?, m: 4); > > It is unexpected to me that this definition will take `$s` before `$f`=20 > in the resulting Closure. The explanation says that the =E2=80=9Corder= does not=20 > matter=E2=80=9D, but it is certainly unexpected that the order *change= s* during=20 > desugaring. > > In fact, the "(four(c: ?, d: 4, b: ?, a: 1))(2, 3);" example further=20 > down below seems to contradict this. The order is determined by the original function. The same is true for = a normal function call. function foo(int $a, int $b, int $c) {} // All of these are equivalent. foo(a: 1, b: 2, c: 3); foo(b: 2, a: 1, c: 3); foo(c: 3, b: 2, a: 1); foo(1, 2, 3); So the same is true of a PFA: foo(a: ?, b: 2, c: ?); foo(b: 2, a: ?, c: ?); foo(c: ?, b: 2, a: ?); foo(?, 2, ?); All of those produce the same result. > 6. > > In the =E2=80=9CExtraneous arguments=E2=80=9D section: > > I disagree with silently ignoring trailing arguments, because it *adds= *=20 > to the existing inconsistency between userland and internal functions.=20 > In fact there was a recent-ish discussion (I would provide a link, but=20 > can't find it right now) about allowing userland functions to define=20 > that they want to be called with a strict arity. > > While it would add to the symbol soup, having an explicit =E2=80=9Cign= ore the=20 > argument at this position=E2=80=9D indicator would be useful. For exam= ple:=20 > `$firstNonZero =3D array_find($arr, intval(?, _));` (I understand this=20 > specific one doesn't work, because `_` is a valid constant). > > 7. > > It is not clear to me from the RFC, why the `...` placeholder to=20 > indicate =E2=80=9Call remaining arguments=E2=80=9D must come between p= ositional and=20 > named parameters. It would make more sense to me for it to become last= ,=20 > because it would also make it clearer that named parameters take=20 > priority over `...`. Is there some technical limitation that caused th= is=20 > choice to be made? I can't find an answer to that in my notes, so I'll have to defer to Arn= uad when he returns. (Ilija tells me he's back Monday.) I think so, bu= t I'm not certain. --Larry Garfield