Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114928 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60926 invoked from network); 17 Jun 2021 13:20:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jun 2021 13:20:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7CB691804D1 for ; Thu, 17 Jun 2021 06:37:45 -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 wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 17 Jun 2021 06:37:45 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 7A1BF1595 for ; Thu, 17 Jun 2021 09:37:44 -0400 (EDT) Received: from imap8 ([10.202.2.58]) by compute3.internal (MEProxy); Thu, 17 Jun 2021 09:37:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding: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=fm3; bh=9Zs9bRmSskcyvy6V+hnxXNr5Vrqvi5cb5642ZvYQ3 jA=; b=gMGRPI9Pk+yR9PgNz37vEiicyehOuNv2mH3vheOV/diqDEUFRi8eM6IjQ TuIxJ56IKOJfyxtd+TaF3d+cU/z3RrrRuWulFu48y/+zBSADaN8NAwIfFO9jw6QQ ROv0OaKuaCFY8UJRBFdZM1a3Ghgcyary54+cChqyPMJark4vOfgHufKa7A8nGN81 QTYejF2R/9SD0oaf+LsPM1KmyBDqRjRMuUk56IHG+9VLMffmnsuwMviPrcRC336X 2bVFkPVfvWU/Vv+KRwkifUlIndasp4x54SQbPnxo1lHsSTEm9hQt4pl9mCzAIW1d W8A52O9Cz3m7ArsBFSOwmdOPVKTxw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeefuddgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeeghefgteejheeggfeghfelueeggfdtjeeivedv tefhveeguedufeelhedvteeinecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id AD2FB3A0430; Thu, 17 Jun 2021 09:37:43 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-526-gf020ecf851-fm-20210616.001-gf020ecf8 Mime-Version: 1.0 Message-ID: In-Reply-To: <20210617095426.7e86bc79@mcmic-probook.opensides.be> References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> <20210617095426.7e86bc79@mcmic-probook.opensides.be> Date: Thu, 17 Jun 2021 08:37:23 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [Vote] Partial Function Application From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jun 17, 2021, at 2:54 AM, C=C3=B4me Chilliet wrote: > Le Wed, 16 Jun 2021 11:16:28 -0500, > "Larry Garfield" a =C3=A9crit : >=20 > > Hi folks. The vote for the Partial Function Application RFC is now = open, and > > will run until 30 June. > >=20 > > https://wiki.php.net/rfc/partial_function_application >=20 > I do not understand how this ... placeholder works, it feels inconsist= ent. >=20 > From the examples: >=20 > > $c =3D stuff(...); > > $c =3D fn(int $i, string $s, float $f, Point $p, int $m =3D 0) > > =3D> stuff($i, $s, $f, $p, $m); >=20 > > $c =3D stuff(1, 'hi', 3.4, $point, 5, ...); > > $c =3D fn(...$args) =3D> stuff(1, 'hi', 3.4, $point, 5, ...$args); >=20 > Why is there an additional variadic parameter in this one? ... means "zero or more". In this case, it means zero, that is, it crea= tes a closure that requires no arguments and will call the original func= tion with all of the provided values later. This is the "deferred funct= ion" use case mentioned further down. > Also, in the second set of examples: > > function things(int $i, float $f, Point ...$points) { ... } > =20 > > // Ex 13 > > $c =3D things(...); > > $c =3D fn(int $i, float $f, ...$args) =3D> things(...[$i, $f, ...$ar= gs]); > =20 > > // Ex 14 > > $c =3D things(1, 3.14, ...); > > $c =3D fn(...$args) =3D> things(...[1, 3.14, ...$args]); >=20 > What happens to the typing of the variadic parameter here? Why is it r= emoved? >=20 > It would feel natural that the ... means "copy the rest of the paramet= ers from > signature". Here it seems it sometimes mean that, and sometimes mean = "accept an > additional variadic parameter and pass it along". Internally placeholders do mean the former. A trailing variadic, though= , can accept extra arguments of potentially not pre-defined types, so it= sort of straddles the line. Variadics make things weird. :-) (Dating = from PHP 5.6.) In the majority case, though, thinking of them as "copy = the rest of the arguments" is accurate. --Larry Garfield