Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114980 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25459 invoked from network); 21 Jun 2021 16:09:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Jun 2021 16:09:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8E4661804C9 for ; Mon, 21 Jun 2021 09:27:14 -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-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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 ; Mon, 21 Jun 2021 09:27:13 -0700 (PDT) Received: by mail-oi1-f170.google.com with SMTP id t140so20559290oih.0 for ; Mon, 21 Jun 2021 09:27:13 -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=RZHwUDIsaPACNgEjMe1S4Eo6M1tDhrlfTHG6RL/fFco=; b=Iqn3hL0DxgFbro7eGEgybiK6Y0B0o5j4uZsR8WmDMXF8eeIaaQAnf7EtQNypJ5YWqO MsxNgjaNIEh6AdA1ld1Aj55ZDAP49mijMhDpsrBXGwGTkTaE3B+4D0Bu3EXK15JORQtR 5v1RvOJ50lwRRyjrKe+QqrxKbw2DP5JFdNxRoVrlL+ctZrGAPsD65Zqr9csT2HIAcH0z PObNe8zsg9we++yG+FWVNAs2yKdeoI6CaM5PL2hLXBdE1tYJKLwxg7XZbv4kWOOMcVpg NJnuZoWeH/QfYKAUhu9Ki5DBdL/nkUZt+add0tKxMa5cqwH3tfARE3NBIOdIecEjOYcS Agww== 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=RZHwUDIsaPACNgEjMe1S4Eo6M1tDhrlfTHG6RL/fFco=; b=e777ovZlvSYuItme9wWwzd91sVx8Pn3fT5FAOGfPAfmUpjdpx0gaV/6sSqvu4D9wxQ E3xev7wum4AZv9iaFbCPTMUvfRuXzlOrgLM2lUdN80EDoycwZgtxrEkvMXXoiLloc/xR Y8gowwpKw565dzcHALI3byvPrG6zvc3DNAS5PrSZVlyVtygDgMoQdNl3BbMa56py9oLE O1b1rVkZW8/UgzrYas/jzckzkfAWS6SBCKwvIqQEe0w1EYfUp0vC6iqbHhO27R5KemnX 5tYUPiUnBiHci5yWPBvVNwTVRVuf1K9W53LnqDnmw2QbaXPAJPi7HuEnJ5SBtBVOeD1X O9lQ== X-Gm-Message-State: AOAM533x/ls3g9se91gnAKONDwVN8lKJIgmpaUr4SG7MYUp0RAM5azAB WHwu4rCuZNY9zJfizg7ak8xtk11M/nNrlj9NejM= X-Google-Smtp-Source: ABdhPJzQzOHX9wSyVNbLhLLKki+jWo9VTQ2vzB0BrElnQT80ZsM1q6gGkmjDYW2k/enD+qPxQt+khi2V5+lBH8cJpOs= X-Received: by 2002:aca:b484:: with SMTP id d126mr24928107oif.80.1624292833162; Mon, 21 Jun 2021 09:27:13 -0700 (PDT) MIME-Version: 1.0 References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> <45b16626-2b04-404b-f5f9-2430004bbdc8@telia.com> In-Reply-To: <45b16626-2b04-404b-f5f9-2430004bbdc8@telia.com> Date: Mon, 21 Jun 2021 18:27:02 +0200 Message-ID: To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Cc: Nikita Popov , PHP internals , Larry Garfield Content-Type: multipart/alternative; boundary="00000000000054f9f505c5492507" Subject: Re: [PHP-DEV] [Vote] Partial Function Application From: krakjoe@gmail.com (Joe Watkins) --00000000000054f9f505c5492507 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I'd like to note a couple of things ... The behaviour of nullsafe and strict types being unspecified in the RFC would allow us to solve those problems later. The behaviour of strict types right now is objectively wrong, the partial takes strictness from the application site, so as Nikita already knew when he asked the question; calls from a non-strict file will not behave as you expect. With regard to the complexity in the implementation: I think it's important to understand that the complexity of the implementation is a product of the semantics we landed on during discussion. The first implementation where we only had ? was technically simpler, but not intuitive from a user perspective. Now we have semantics that are easy to understand, that you can communicate in a few lines. But the implementation is necessarily complicated as a result of those semantics. We also have to remember that this is actually some kind of middle ground, it's not the most complicated version of partial application we could have - because that most complicated version would also include support for re-ordering parameters (named placeholders), and nor is it the simplest which offloaded a lot of (cognitive) overhead onto the programmer. The question is not can we simplify the implementation, the question is rather, is the necessary complexity of an implementation with the kind of semantics that are desirable justified. Cheers Joe On Mon, 21 Jun 2021 at 16:26, Bj=C3=B6rn Larsson via internals < internals@lists.php.net> wrote: > Den 2021-06-18 kl. 16:08, skrev Nikita Popov: > > 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 placehold= er > >> 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 !=3D=3D null ? $foo->bar(?) : null. I don't think t= he > > 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(?, ?, ?) y= ou > > 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=3Drfc.partials To be honest, I'm not s= ure > > 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 t= he > > 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=3D1 file and call it in a > > strict_types=3D0 file, what happens? Will it use strict_types=3D0 seman= tics, > > including for arguments that were bound in the strict_types=3D1 file? > > > > * It's worth noting that the "new Foo(?)" syntax will create and destro= y > 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 convince= d > > that PFA in its full generality is justified for inclusion in PHP. > > > > Regards, > > Nikita > > > Would you look on this feature in a different light if the above > concerns about strict types and nullsafe calls could be clarified / > solved? Or is it about the implementation with it's complexity and > tricky edge cases? > > I myself think one should take into account that this is a feature > that would make PHP stand out even more. Not being a follower of > other languages here :-) > > Regards //Bj=C3=B6rn L > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --00000000000054f9f505c5492507--