Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128187 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 E38931A00BC for ; Wed, 23 Jul 2025 08:56:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753260900; bh=vamf41c7q/SYs5lSbwW3/vx8v4MLb09qzVuIVrDg0Lg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gl0IHWDz1L7bxo2t2rRWJQe1DGGOS4bbZL/kGOkcynVsAckyqBDplSqoq0dyw+tgN +ftZtuP6CjXp9m7cbK3b8EE8GyeMEfIvfUEIDSiFalCu7aTVTEn/Sz5px/5hdul7VP sHiWDH0tJeXlU21Pgoad7RUIwHrvbghYpo5zfiKyy1lml5yhxriIpzwXLtXbvdhfIl tTEhq7d27ldWGFRTBB9cNW8BifAtAl3yCTYEQK35g2E+BzMEBSdGyRH78vuERppjaj jpFVAVYZFcQdjnN+t5XM0i3KQnBIe8XTdbeRVVqDh9/enCcj0wpFYuaHEXM+paJ5eP 32gY3Pr4EaR9A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F102C180083 for ; Wed, 23 Jul 2025 08:54:59 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS 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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 08:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1753261002; bh=Qyx2x/oBTLDeCWdHWIUIQSI7LJS/0zTU5vb+2F3Nbjc=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=K8bknTLYQCu/olVIt2y9x7VchFGTTgMgsyCXBy57rBGeXvDT0aQEsfMXZyCnReToe MXt7ZUhkxW7DwyeKJE4cqjwhZRU8ayNB85MpSfDevlLuRqvTOBCUdb77O4ahkElfMa EgRFGoQ/hkcgWn7zJGf72Evs3gTVEOT0umcwLcccN801YYR4olWDdJAPE7Bc7NrA1+ xd9lPG1dmaqDPy5kv8c0WrhVT6a4XzRQW0tCq3Vblxj5wUIFo9myFNpHKMcwQA2KSj V+3WA+OjATynKIeZOf+WnBqaqPiehXB1xnPrh0UesyJbOj+R5wmiLclZ+6d1K2H8pV jEp9rT61ju1Yw== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Wed, 23 Jul 2025 10:56:42 +0200 To: Larry Garfield Cc: php internals Subject: Re: [PHP-DEV] [RFC] Partial Function Application v2 In-Reply-To: References: Message-ID: <52dbe5236df460958644677c781513c3@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) 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: > > - Any positional placeholders that run into the variadic portion become > required. > - If any positional placeholders run into the variadic portion, all > prior remaining placeholders become required. However, those parameters > may not be called with named arguments, as there is no name to use. I do not understand what “running into the variadic portion” means. An example would probably be helpful. The first bullet point is probably intended to mean the following: function foo($a, ...$b) { } $pfa = 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. 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 section either. Including the desugaring of this extreme case would certainly help understanding. 3. In the “Examples” section: The choice of parameters names makes it hard to understand the examples, particularly when named parameters are used to provide arguments out of order. Including the “position” in the name of the parameter would make it easier to follow the example, since it is not necessary to look up the signature of `stuff()` all the time. (it becomes manageable if you read it as a sentence "is FPM") 4. In the “Examples” section: Is the “thunk” example accurate? It's the only example where the resulting “PFA” includes a variadic picking up the remaining arguments. 5. In the “Examples” section: > $c = stuff(?, p: $point, f: ?, s: ?, m: 4); It is unexpected to me that this definition will take `$s` before `$f` in the resulting Closure. The explanation says that the “order does not matter”, but it is certainly unexpected that the order *changes* during desugaring. In fact, the "(four(c: ?, d: 4, b: ?, a: 1))(2, 3);" example further down below seems to contradict this. 6. In the “Extraneous arguments” section: I disagree with silently ignoring trailing arguments, because it *adds* to the existing inconsistency between userland and internal functions. In fact there was a recent-ish discussion (I would provide a link, but can't find it right now) about allowing userland functions to define that they want to be called with a strict arity. While it would add to the symbol soup, having an explicit “ignore the argument at this position” indicator would be useful. For example: `$firstNonZero = array_find($arr, intval(?, _));` (I understand this specific one doesn't work, because `_` is a valid constant). 7. It is not clear to me from the RFC, why the `...` placeholder to indicate “all remaining arguments” must come between positional and named parameters. It would make more sense to me for it to become last, because it would also make it clearer that named parameters take priority over `...`. Is there some technical limitation that caused this choice to be made? Best regards Tim Düsterhus