Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115245 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59899 invoked from network); 30 Jun 2021 16:50:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Jun 2021 16:50:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B14071804B3 for ; Wed, 30 Jun 2021 10:11:08 -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) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 30 Jun 2021 10:11:08 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id C55AA3200930 for ; Wed, 30 Jun 2021 13:11:06 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Wed, 30 Jun 2021 13:11:06 -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=0eYbn41gLuH828Ax/A9XqskluvbGIZEaCEumokxdz LU=; b=RfCu7tNDXrSHz7cJTK0rkHuAGlQmrvHBEwjVxFzWsjL1PN4zYXOOfAPfs ZSMPD4gVMOo6F98zdFzQ618FwoFw7t9i93PZPisET1mA4gylzHPdZObXeR8JLnZQ iUIXieJZI0pVhr+aqn7Y+vmoQuUfZAG0UKTL45Z/E3QJ3arnLhUS+9l2m1cuzyOA J9ATfjNDiBB2N48TdfVgmRIoAQrLrRYfgB4U9Rqfa/T0Zk6guRn6dW31DPX1ReFP TSM8j+AChO0iHb4N6zIyaezQqk8a3OLKEIuoVpjJFzuic8bbMK/TTxv7w5nUNJpi 3skeL+pTlu0/LaogjzQzNZaHB5BMg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeigedgudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepffffffejffdugfegvedviedttedvgfejffefffej leefjeetveehgefhhfdvgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 35FFBAC0073; Wed, 30 Jun 2021 13:11:06 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-530-gd0c265785f-fm-20210616.002-gd0c26578 Mime-Version: 1.0 Message-ID: <8e6ad5a6-f627-4e3f-af04-6384ab6147f0@www.fastmail.com> In-Reply-To: <17a5d374765.1289062a2301127.8166821672739325531@limesurvey.org> References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> <9f0c9565-22e1-4d94-bef5-cfc44ce02dc5@www.fastmail.com> <17a5d374765.1289062a2301127.8166821672739325531@limesurvey.org> Date: Wed, 30 Jun 2021 12:10:37 -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 Wed, Jun 30, 2021, at 8:59 AM, Olle H=C3=A4rstedt wrote: > > I've been pondering if a completely different approach with a prefi= x=20 > > symbol would be able to be less complex, and the simple answer is I= =20 > > have absolutely no idea.=C2=A0 But we are running low on symbols...= > =20 > Ah, I found the technical details that Joe gave me (right after I hit= =20 > send, of course).=C2=A0 Quoting Joe: > =20 > "the engine expects certain things to happen, and is designed and the= n=20 > optimized around those assumptions ... for example, a stream of INIT,=20= > SEND, DO_FCALL is not meant to be interrupted, the first fundamental=20= > change you have to make is making the engine aware that stream of INIT= ,=20 > SEND, + are not always followed by DO_FCALL " > =20 > So yes, it sounds like hooking into the function call process is wher= e=20 > the complexity comes from.=C2=A0 Which suggests that an approach that = works=20 > using a different syntax that desugars to a closure would avoid that=20= > issue, but then we need a syntax that wouldn't be ambiguous, and that'= s=20 > getting harder and harder to find.=C2=A0 (Nikita's first-class-callabl= es RFC=20 > notes some of the issues with available symbols, and they're=20 > essentially the same for partials either way.)=C2=A0 And I've been tol= d that=20 > creating closures in the AST compiler is Hard(tm)... > =20 > --Larry Garfield >=20 >=20 > Wrapping stuff in lambdas is otherwise the obvious solution, no? Make=20= > `strlen(?)` evaluate to `fn ($x) =3D> strlen($x)`. Does it depend on t= he=20 > level of look-ahead in the compiler why it's so hard? Didn't work much= =20 > with scripting language internals. >=20 > Olle The tricky part is that conversion has to happen entirely at runtime, be= cause we need the type information from the function being partialed, an= d at that point creating an actual closure is, apparently, rather hard. = It cannot be done up at the AST level where it would be conceptually mu= ch easier. We've been discussing this for the past several days in chat, and the ba= sic conclusion is that the PHP engine does not offer any easy way to do = this. It's one hard-and-messy approach or another hard-and-messy approa= ch. So far no one has figured out a not hard-and-messy way to make it w= ork, regardless of performance. --Larry Garfield