Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114481 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40700 invoked from network); 15 May 2021 00:11:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 May 2021 00:11:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2D1761804D8 for ; Fri, 14 May 2021 17:20:18 -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=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mercury.negativeion.net (mercury.negativeion.net [199.38.81.6]) by php-smtp4.php.net (Postfix) with ESMTP for ; Fri, 14 May 2021 17:20:17 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mercury.negativeion.net (Postfix) with ESMTP id 9A7F320D86FB06; Fri, 14 May 2021 20:20:17 -0400 (EDT) Received: from mercury.negativeion.net ([127.0.0.1]) by localhost (mercury.negativeion.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mvw1uYLXZDhA; Fri, 14 May 2021 20:20:17 -0400 (EDT) Received: from [10.0.1.102] (unknown [173.225.146.47]) by mercury.negativeion.net (Postfix) with ESMTPSA id 1549A20D86FAF5; Fri, 14 May 2021 20:20:17 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) In-Reply-To: <77e233b3-8046-4992-83e4-675d26712091@www.fastmail.com> Date: Fri, 14 May 2021 19:20:17 -0500 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: <4F5C67CA-9079-4BFE-9786-3CB307E2138A@trowski.com> References: <1565EB81-57B7-49B0-A47C-342E0088A432@trowski.com> <532D1413-52FF-4403-A20B-BBDB51163C85@trowski.com> <77e233b3-8046-4992-83e4-675d26712091@www.fastmail.com> To: Larry Garfield X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] [RFC] Partial function application From: aaron@trowski.com (Aaron Piotrowski) > On May 14, 2021, at 7:00 PM, Larry Garfield = wrote: >=20 > Is that actually going to come up? Given that PHP functions (at least = user-space ones) accept extra trailing arguments and just let them fall = off, I would *expect* a closure that way to do the same. Named = arguments continue that, I believe, by just ignoring any variadic = arguments that do not match a parameter in the function. It seems odd = to go back on that behavior now. I don't consider forwarding extra arguments an issue. I briefly was = thinking it might be nice to be explicit about the number of arguments a = partial would accept, but you convinced me otherwise in R11, so I think = we're on the same page here. >=20 > I can't speak for the others, but I could tolerate making "more than = one extra ? beyond the end of the parameter list is an error", = potentially, as at that point they're redundant. But if a function has, = say, 4 params, then fourParams(1, 3, ?) is a convenient way to say "and = placeholder everything else". Especially in dynamic cases like Nicolas = pointed out, you may not necessarily know how many arguments there are. With what I proposed in my last email, `fourParams(1, 3, ?)` is = acceptable, there's nothing superfluous there. At least one ? is needed = to declare a partial. Similarly, a partial for a no parameter function: = `$partial =3D functionTakingNoParams(?)`. Or even a partial with args = bound to all four params: `fourParams(1, 2, 3, 4, ?)`. What would error is `fourParams(1, 3, ?, ?)`, as the second ? is = meaningless. I think you've convinced me that one-for-one matching on ? is = burdensome, but the above is a happy medium perhaps? Cheers, Aaron Piotrowski