Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114482 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42892 invoked from network); 15 May 2021 00:28:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 May 2021 00:28:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D1CCD1804BD for ; Fri, 14 May 2021 17:36:55 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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, 14 May 2021 17:36:55 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id EE1E55C0164 for ; Fri, 14 May 2021 20:36:54 -0400 (EDT) Received: from imap8 ([10.202.2.58]) by compute4.internal (MEProxy); Fri, 14 May 2021 20:36:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=uHfTyh Z2nu4Y0Xw4l7jRmVO2giQgFrS4jrDVxz5KeFk=; b=je7u6bQx+UR02jk1LQQafc +Ncgu7WaDODKtqAFD2yozeZ62S3RR/fJkDlArPXpmyyveoIkuORfWrzmZhBlalIe ppLSG6Yzwqtk6zpkrFA8fwy1XrFZRZ/BmRjDVORHWcdmo5F8NwoZmSXOMHFTxkic ha9Pw2glnnfbR8a+PINwFET/hPXsDbTa2P7oCRHf7Dcu+v5NjtVMiI51fQnFPmZ2 42VbE1HNr/0APQsbeYKnmL22xQEEvM7Up+GbZvgV3Bxg4jEYz0vA1e6aMD6/hIK4 3dTAzdB9HB6FzjXx4as/aIXYz8S7j6ZlP1JmGMsGVxYZs2nmO6t7a2REcf8hPt7A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdehkedguddtjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8E8CA3A0130; Fri, 14 May 2021 20:36:54 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-448-gae190416c7-fm-20210505.004-gae190416 Mime-Version: 1.0 Message-ID: In-Reply-To: <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> <4F5C67CA-9079-4BFE-9786-3CB307E2138A@trowski.com> Date: Fri, 14 May 2021 19:36:33 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Partial function application From: larry@garfieldtech.com ("Larry Garfield") On Fri, May 14, 2021, at 7:20 PM, Aaron Piotrowski wrote: > > > On May 14, 2021, at 7:00 PM, Larry Garfield wrote: > > > > 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. > > > > > 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 = 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? I'd be OK with "no more than one trailing ? in excess of what the underlying callable has." (Which means if you don't know, just stick one ? at the end and you know it will work.) --Larry Garfield