Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128824 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 31AE51A00BC for ; Mon, 13 Oct 2025 18:24:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1760379856; bh=a2LiEBDb1qZF1oI9Kcvh8SwL3ih3mOCp7IF1wFWNSog=; h=Date:From:To:In-Reply-To:References:Subject:From; b=TnvGOj+2gkNvgJogNr+2a0qQiCGdR7u9tuka1q/x9hTi8SkQZgYZGl6NM+p3FF1xB 3jBSfgpmwTfJm6qrMzYXLomAN2fW74UdF4rhtt82MihgZ9QmyC2ZcH+x1/4xWhqyaI QGl7fvBJfbXe/55lO+ah1QOJg+SrgMXoD2J2AOZGWtAFRM8TwucKhzifmdh98JQ+24 fJjq4uug7YPZisb4xykKge/nL6jPI3DGKHy0CcrbO7duhWPYSgoP1QNIM1MAhXleug mUQm2pyF9qJO+sv2OqWyx0CXLKYmlJ0rJJ0u4/DibN9zv2KF/WcchkWUTkODHg0RqF yP4rD5/hwsX+w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D9E891804A7 for ; Mon, 13 Oct 2025 18:24:15 +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: No X-Envelope-From: Received: from fout-b4-smtp.messagingengine.com (fout-b4-smtp.messagingengine.com [202.12.124.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 ; Mon, 13 Oct 2025 18:24:05 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id E93061D0016C for ; Mon, 13 Oct 2025 14:23:59 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Mon, 13 Oct 2025 14:23:59 -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=1760379839; x=1760466239; bh=JbnV7b8/Ddyl7t5ULaCHP 5zDQR24ZlvYC7ZgnynoKR0=; b=YNfe5aJvhJyj+R1wvRuWPacBgUieGsY5bmOoy OYp5F/DqAO3A513N0+4EVpVY+4SQJ5UjdB8XVec+g2hMY/0m0OPa3G4b2w6D0/LV u3RX1PQ4WLblf6kHlOIZoyePhJF9cneTuYVwjTi1wm1hDzF8GlvJgH54MvIxMP34 fPHKVJoXAiosAquoLDIuuUIgiGLylAo3NwZVHSVUC+xC8CLURh6OWFTtsq3xDuPS AEiu5WWwMA10xjlPx1GoJq4gIEjyDykSojZP9711s5+3zFSGpUudx/gTRPGJo+t+ vG0JB3DgFaRj/0o+Jy6RAF01RDp+zz0L0o8T1MEe9nojK7MSQ== 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=1760379839; x=1760466239; bh=J bnV7b8/Ddyl7t5ULaCHP5zDQR24ZlvYC7ZgnynoKR0=; b=EgYRFKlzRmvJxU7jc sRWRZGDHDb5XaegJlgUB4/z5fNbgts8uy5TQ09q1KJU2jd1TKm28swQtIpQAo2El AavBjXdgmZoOj8uZIlHNSpNhH+hlAn6ReXtMRfG2YEOy8Y084d91hfdE7QLvJ1wO FatzZtBbyUsKdM18ilfVWFrzNh+2RP8Q9xAeJVu0YmwwGkMXqDexADp+smo+YSd9 uoQOS5lsBvC01RSjyRZpNB2LJHzl+8WSkLATWMneShUwqn2cg/VKlPCd8IAVQhcA RidYH1ZiyzCFsC1Yp4noO8kQ3ceNkaXt32GEyGQ6pY2Oe7m70cKAbGTDKowsS14W GL1GQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduudekfeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdegteeiueegvefhteehfeeffeet udeitdehtdegjeeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghp thhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsh eslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 5CFB1700054; Mon, 13 Oct 2025 14:23:59 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: ATrodGnf_4Xg Date: Mon, 13 Oct 2025 13:23:38 -0500 To: "php internals" Message-ID: <17c4de1b-96bd-424f-b1ed-637cfc961464@app.fastmail.com> In-Reply-To: References: <13830641-0fb9-4de9-94ed-8873045ef820@app.fastmail.com> 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 Sun, Oct 12, 2025, at 1:35 PM, Tim D=C3=BCsterhus wrote: > Hi > > On 10/10/25 17:26, Larry Garfield wrote: >>> What will happen if the original function already has a parameter na= med >>> $args0? >>=20 >> It will skip over existing names. I've updated the text accordingly. > > Okay. Looking at all the examples, I think it would be nice if it woul= d=20 > not use the generic `arg` prefix, but use the original name as the=20 > prefix. For the > > function foo(int $a =3D 5, int $b =3D 1, string ...$c) { } > > example, the 3rd and following parameters could be `$c_1`, `$c_2`, =E2= =80=A6=20 > (still skipping over duplicates). OK, there was a miscommunication between Arnaud and I. It is using the = variable name, not "args" already. Just with no _ and 0-based. I've up= dated the RFC accordingly. > Okay. Now looking at the examples: > > $c =3D stuff(?, ?, f3: 3.5, p4: $point, ...); > $c =3D fn(int $i1, string $s2, int $m5 =3D 0): string =3D> stuff(= $i1,=20 > $s2, 3.5, $point, $m5); > > and > > $c =3D stuff(1, 'hi', 3.4, $point, 5, ...); > $c =3D fn(...$args): string =3D> stuff(1, 'hi', 3.4, $point, 5, .= ..$args); > > seem to be inconsistent with each other with regard to whether or not=20 > "superfluous" arguments are passed through. > > This might (or might not?) be explained in the =E2=80=9Cfunc_get_args(= ) and=20 > friends=E2=80=9D section, but is unexplained at the point the example = appears.=20 > Also within the func_get_args() section, there is no explicit `...$arg= s`=20 > in the resulting signature, but instead the desugaring uses=20 > array_slice() + func_get_args(). We talked a bit more, and decided to tighten the rules further. I've up= dated the RFC accordingly. Essentially, the first example is correct, t= he second has been changed. If the underlying function is variadic, and ... is used in the PFA, then= it will accept an arbitrary number of arguments. In any other case, on= ly explicitly-specified arguments will be passed through. > Thank you, I'm seeing you added an example. I've a small request to=20 > hopefully make the example more useful: It currently uses only=20 > =E2=80=9Cplaceholder=E2=80=9D parameters. It would be useful to also a= dd one pre-filled=20 > parameter to it. I would assume that this pre-filled parameter does no= t=20 > appear within the Closure frame, but appears with the frame for the=20 > actual function? Updated the error dump example. > - How does it interact with `compact()`, specifically: > > $partial =3D compact(someValue(), ?); > > Would the `?` be able to capture a variable containing the return valu= e=20 > of `someValue()`? Good question! compact(), extract(), etc. can't actually work with PFA,= because they operate on the ambient context, which PFA by design change= s. I've updated the RFC to note three incompatible core functions. (Th= e other is func_get_arg()). =20 --Larry Garfield