Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114978 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16213 invoked from network); 21 Jun 2021 14:08:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Jun 2021 14:08:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5B3971804D0 for ; Mon, 21 Jun 2021 07:26:17 -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=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_RP_RNBL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from ts201-smtpout71.ddc.teliasonera.net (ts201-smtpout71.ddc.teliasonera.net [81.236.60.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 21 Jun 2021 07:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telia.com; s=tssemail; t=1624285577; bh=oYyOOTB001kk75l7W+On4ZLObuBlG9O+1lMg+R5UXEw=; h=Subject:To:References:From:Message-ID:Date:MIME-Version:In-Reply-To; b=KpMGILO+p5oTYbTqESSolOWfUcO5exc8aPdMlbg3O+UpPAXUpIWfu0EoKSuy+iPypoNc3hrWYggiRP+3QkSAFSfldftN4c61RCIXyzRAoABaYyC1cxPhb0SPt5rLqM/xPMUtunaZmbPYQqo2yXXUh3SoFPGTZ6Edv2uEZJ/EYVVZEo5v7F1x1rrDjk6xof7JncHj/gccmjTFEL6jX/LnTLRs67J2iK1mYeY/BYBbE3PnduztcIe9r32b2hqpROhZyJzWZTthU/IMiYvaybXeImwnzlt9tR6LiS9yQMvR0NX0gJTXMY4u8tVtDw2le1kXEQAN3HKhUFvG/YP0b1vFBg== X-RG-Rigid: 60C47169007B1287 X-Originating-IP: [213.64.245.126] X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgeduledruddugedgfedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuvffgnffktefuhgdpggftfghnshhusghstghrihgsvgdpqfgfvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomhepuehjnphrnhgpnfgrrhhsshhonhcuoegsjhhorhhnrdigrdhlrghrshhsohhnsehtvghlihgrrdgtohhmqeenucggtffrrghtthgvrhhnpeegtdekfefgueduudelhfffgeektdduuddugeeuffekgfdtieegudfhheelgfdvueenucffohhmrghinhepphhhphdrnhgvthdpfehvgehlrdhorhhgnecukfhppedvudefrdeigedrvdeghedruddvieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopegludelvddrudeikedrjedruddungdpihhnvghtpedvudefrdeigedrvdeghedruddviedpmhgrihhlfhhrohhmpehukeelledtieegudejsehpnhgvrdhtvghlihgrrdgtohhmpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvthdprhgtphhtthhopehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdprhgtphhtthhopehnihhkihhtrgdrphhpvhesghhmrghilhdrtghomh X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from [192.168.7.11] (213.64.245.126) by ts201-smtpout71.ddc.teliasonera.net (5.8.716) (authenticated as u89906417) id 60C47169007B1287; Mon, 21 Jun 2021 16:26:07 +0200 To: Nikita Popov Cc: PHP internals , Larry Garfield References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> Reply-To: =?UTF-8?Q?Bj=c3=b6rn_Larsson?= Message-ID: <45b16626-2b04-404b-f5f9-2430004bbdc8@telia.com> Date: Mon, 21 Jun 2021 16:26:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: sv Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [Vote] Partial Function Application From: internals@lists.php.net ("Björn Larsson via internals") 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 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 > 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örn L