Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114952 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98078 invoked from network); 18 Jun 2021 13:51:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jun 2021 13:51:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 42F1F1804CC for ; Fri, 18 Jun 2021 07:08:52 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 18 Jun 2021 07:08:52 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id x14so14207864ljp.7 for ; Fri, 18 Jun 2021 07:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XPQc4HLtwNt94gP96lXtrajh0RkWi1SguQuBB+G8wwo=; b=nKe5lNRCg23Gsc1ByGQog+/Idn03NVSdv2WSDPjVUnD5YhGocdAjciaSz+CCMrWnu0 EtX1W965++ixW8M/bTR4VcJURjSS7foVqQw6aVq4X+D1Y8nphXzjrpz6gVQELch4qJwS XW8iAuoQsibqLZH8NusYSj6duL+IlnVdEwojlOn4npN4LdT5KfSQpuo2ajG7w2NKdf6F gWNiM/ntlhNvvwtUmAHZXbWAUeOoqKh2LC6AdFB7zEiljZultFMPI64MAubo9NhDosf3 uZcTNTXe0UwTDz7Gnn6sQgAyTZBuyUBqAWZPjyp9m2hAcVy2/s/RXDXZZ6Bgvt85z2/M gikg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XPQc4HLtwNt94gP96lXtrajh0RkWi1SguQuBB+G8wwo=; b=pMYsBK8HPh9iIt2TNLSeD/noiRGFLmkdNvbg55ZTWXHYBISha1YbVu+tHSYDUYYNrN v0MATyaUQcI6GeI16J8GCXvZMkx7fGMsdr7JKvUBI/TsaB5YsbVnl4RGbWD/IiejiYRe 59JdSsBZLYtm+Wp/GbR+dRyq30r28WpfEYwy+koTUvlzYPRnqdG9oJEe4flx73UIUQbO Ls4VSp2owJV0LxdgklBgp9GqUG+7YdS/nxJC7703bZqYA1Ec3mqhlIgbUxAE18a8X9Yn BIzKVs/pdC+KDoWhSAyTwtkJ3AOVkfXYg88v1X49YHzN3JMs8Gpop7cvrcvA6k5SMoMi 9GEw== X-Gm-Message-State: AOAM533iv5IXt97F31RcsfBhAzBiIr+C8UzD9e1MMJYRPhlVXDNdSe/D hKC3myXFNmGpKlqJhWdq1fr9qckLJJABnR4rKRRpHKnabB6cag== X-Google-Smtp-Source: ABdhPJzcKlP01gqghB9h+ZsTVcIh42UlxfFhjGmdywQLtp0dP39qES+iTGB862sVZBE86TzsV2oyGrpwAZSeZ3mwZzI= X-Received: by 2002:a05:651c:604:: with SMTP id k4mr9605808lje.244.1624025329664; Fri, 18 Jun 2021 07:08:49 -0700 (PDT) MIME-Version: 1.0 References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> In-Reply-To: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> Date: Fri, 18 Jun 2021 16:08:33 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000e1873405c50adcc0" Subject: Re: [PHP-DEV] [Vote] Partial Function Application From: nikita.ppv@gmail.com (Nikita Popov) --000000000000e1873405c50adcc0 Content-Type: text/plain; charset="UTF-8" On Wed, Jun 16, 2021 at 6:17 PM Larry Garfield wrote: > Hi folks. The vote for the Partial Function Application RFC is now open, > and will run until 30 June. > > https://wiki.php.net/rfc/partial_function_application > > Of particular note, a few people had asked about using ...? instead of ... > for the variadic placeholder. In the end we decided not to explore that, > as Nikita explained off-list it was actually more confusing, not less, as > it would suggest "placeholder for a variadic" rather than "a placeholder > that is variadic." Otherwise, it's just more typing. The syntax choices > section of the RFC has been updated accordingly. > A couple of notes on the content (or non-content) of the RFC: * The behavior of nullsafe calls with PFA has been brought up in the discussion, but is not mentioned in the RFC. For reference, $foo?->bar(?) is the same as $foo !== null ? $foo->bar(?) : null. I don't think the behavior is particularly unreasonable, but I also think it's not particularly useful and may be surprising (in that there is a plausible alternative behavior). I think you may have been better off forbidding that case. * The behavior of parameter names / reflection with regard to variadic parameters is very odd. For function test(...$args) and test(?, ?, ?) you get back a function that nominally has three parameters with the name $args. Parameter names in PHP are generally required to be unique, and of course this also has implications for named arguments, for example this works, while it probably shouldn't: https://3v4l.org/cQITD/rfc#focus=rfc.partials To be honest, I'm not sure what the right way to handle this is, but I don't think this is it. A possibility would be to bring back the concept of name-less parameters we had prior to PHP 8 (for internal functions only), or possibly to make the signature less precise by simply retaining an ...$args parameter, and just making the enforcement of "at least three parameters" an implementation detail. The latter seems like the best option. * The RFC doesn't specify how PFA interacts with strict types. If I create a partially-applied function in strict_types=1 file and call it in a strict_types=0 file, what happens? Will it use strict_types=0 semantics, including for arguments that were bound in the strict_types=1 file? * It's worth noting that the "new Foo(?)" syntax will create and destroy a Foo object as part of creating the partial (not just a call to the partial). I've mostly convinced myself that this is *probably* harmless. It would have interacted negatively with an earlier version of https://wiki.php.net/rfc/new_in_initializers, but I think the problem there was not on the side of partials. In any case, I'm voting no on this one: While PFA is simple on a conceptual level, the actual proposal is complex and has lots of tricky edge cases. Especially once you take a look at the implementation. I'm not convinced that PFA in its full generality is justified for inclusion in PHP. Regards, Nikita --000000000000e1873405c50adcc0--