Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128804 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 309C71A00BC for ; Thu, 9 Oct 2025 21:39:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1760046003; bh=J9tnIT5/hkRVftbP1w0zaslCZcSCJ8gihtAEUGl2bWc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dbCcwYvtzao/d36VhTknQ73yHoi/ewI9o2wzpnaxqF3gQtyIrgY6u7KDmOCFMSdZw A7SYPgnkXKeJwrs2qXb9RI33MPMCaMGptkyo102pIg3nZ8bPk9i02No10tj5PZGU5C YYX5B6xJTy75qaoo0QxBYC/TfDMqzQoTU/cPxE1ajRBgHdGGxoDXzqBpldeQnuMK1L O8JWVJF5LVtovQVJ+dG9o8XNsoKqvfyy5JJdTeG0ri3V4fX+hQD9xkId1Xm0kKiI25 BVvKrG3cgeq1TQ2AdL6u+YcOXPs5slEuGab0pAmHEWXTk1MZA5I2VBf95pD4CDrvWU AUybGA0zLi58Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 03D881801E8 for ; Thu, 9 Oct 2025 21:39:58 +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: No 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 ; Thu, 9 Oct 2025 21:39:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1760045990; bh=yzb2cTAdkmBIp5etC5m5QFAD83+12BGPzlMJ67dBJWE=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=UCrZdA4LJoPWbr8aumsK/OMykzcyK60d03MNsmD0n25lgi+50M81etlBhkU12euiY eoGi/lmSrg6ux3I+crck3pdo4BWC7iL3UGB32sktIvAuoXCXTvvsHIOSyRI8S1hcQf gFy3BqZ92LmapdI7ESw+3TNTrwK1j5H4Qxyr1n90TrV7EbEQa1kH5g/8Oqdx0FLX4Y IwO56WW59/f3ThM+mhjm9K0yG1IvqjcUimj7hsyYLSLTIMdtoT4+UU9KVgjVaF5QzL EKcoy9IdSmZiWQgCJfsmJaXiWMRyBjXlHFP44pY7FxRhEScxggkswwFlz4GIO08YK4 MH4fJcTEiuimw== Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 09 Oct 2025 23:39:50 +0200 To: Larry Garfield Cc: php internals Subject: Re: [PHP-DEV] [RFC] Partial Function Application v2 In-Reply-To: <13830641-0fb9-4de9-94ed-8873045ef820@app.fastmail.com> References: <13830641-0fb9-4de9-94ed-8873045ef820@app.fastmail.com> Message-ID: 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-10-09 20:54, schrieb Larry Garfield: > One outstanding question is whether to allow reordering of parameters > in the PFA closure by using named arguments. With this implementation, > Arnaud says it's possible to do if we decide to. I am still concerned > that it would create too much complexity and confusion in practice. > But we're willing to go with a broad consensus if it emerges. I still believe that this is *less* confusing, as I outlined before. > https://wiki.php.net/rfc/partial_function_application_v2 I've given it another read. Remarks: > Positional placeholders that map to the variadic portion of the > underlying function will be named $args0, $args1, etc., and may be > called by name if desired. What will happen if the original function already has a parameter named $args0? > stuff($1i, $s2, $f3, $p4, $m5); Typo: 1i. > Prefill all parameters, making a "delayed call" or "thunk" The example desugaring is inconsistent with the previously explained semantics: Here an arbitrary number of arguments is accepted, but previously it says "will result in a Closure with no parameters". > // Placeholders may be named, too. Their order doesn't > // matter as long as they come after the ..., if any. I believe this example is outdated, since the ... must come last now. (the 's' and 'i' parameters are also missing the "number"). > $c = fn(int $i1, ?float $f3, Point $p1, Point $p2): string => > things($i1, $f3, $p1, $p2); This example desugaring seems to be incorrect with regard to the naming of the variadic parameters. > (four(c: ?, d: 4, b: ?, a: 1))(2, 3); Just to spell this out explicitly: I believe this should print "1, 3, 2, 4". > $eMaker = fn(int y): E => E::make(1, $y); `$` missing before `y`. > $c = stuff(?, ?, ?, ?, ?, ?); The error message for this one appears to be a copy and paste error. > // throws Error(Named parameter $i overwrites previous place holder) Is it actually "place holder" with a space? > $c = stuff(i:1, ?, ?, ?, ?); Minor formatting nit: Missing space after colon. > $inter = fn(mixed ...$args): int => intval(..$args); Typo: Missing dot in splat. ------ Questions: - Are PFAs legal in constant expressions? e.g. does the following work: `const Foo = intval(?, 10);`? - The RFC says that it compiles down to the equivalent Closure. Can you add an example of a stack trace for completeness? Ideally one with SensitiveParameter working. That will then showcase the closure naming, SensitiveParameters and that there are two stack frames for the call. Best regards Tim Düsterhus