Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115241 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42003 invoked from network); 30 Jun 2021 13:38:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Jun 2021 13:38:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 862A0180501 for ; Wed, 30 Jun 2021 06:59:05 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from sender11-op-o11.zoho.eu (sender11-op-o11.zoho.eu [31.186.226.225]) (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 ; Wed, 30 Jun 2021 06:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625061542; cv=none; d=zohomail.eu; s=zohoarc; b=iVjsU7dIqu19dFz/9qfCvGl0U0yLGh2lCjwZ+N9UI58r5Dfex/vgAcMc9qweK7NYp2p8wRmZHPx+7bKefjGImQkuaqQYKwaih5TB2yQyaDzaTE7fADCzbEouIcLot4FXyEsTsqWCsOkHmd5jmLTcdYnUCi3Cs2wWpp8GdtJCOx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1625061542; h=Content-Type:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=bbMcVJV5eawgMCzuezH2ivRSB/pId52t4ZfGq5ihrfA=; b=ZiZA3/6jvsJlmPkAWeVCmYp07MFWrU/vaoKdlY6x+j0aMHHVu689sU91OJg88CpRhLJqK9qhffrajtDAZjmPIO5PEQGB+zpdrWERHkq7zlwa0l+gzL72fieUBukHsyuDxRioIxAc055egPkAmOyibWEzuDsiHnGfyPUMC00hKxY= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=limesurvey.org; spf=pass smtp.mailfrom=olle.haerstedt@limesurvey.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1625061542; s=zoho; d=limesurvey.org; i=olle.haerstedt@limesurvey.org; h=Date:From:To:Message-Id:In-Reply-To:References:Subject:MIME-Version:Content-Type; bh=bbMcVJV5eawgMCzuezH2ivRSB/pId52t4ZfGq5ihrfA=; b=XiYepfcbTgUnYETz1vWhY9y7pVwXGkljTbZ6Sq0cfRIIXkIO/Qv9KpKqeq0+jgbX 2kifEd8FcSNMsPESp40mykOJp7MU5VgBuhLcbjsqnLbmnXLHOs3itCZGOvU8wSOA4ta 9El1L/VyzU4AVIO6bStkeAcJ9QdMDR5btxBczgiI= Received: from mail.zoho.eu by mx.zoho.eu with SMTP id 1625061541736395.3197241659657; Wed, 30 Jun 2021 15:59:01 +0200 (CEST) Date: Wed, 30 Jun 2021 15:59:01 +0200 To: "internals" Message-ID: <17a5d374765.1289062a2301127.8166821672739325531@limesurvey.org> In-Reply-To: References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> <9f0c9565-22e1-4d94-bef5-cfc44ce02dc5@www.fastmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1041287_1840044666.1625061541733" Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail Subject: [PHP-DEV] [Vote] Partial Function Application From: olle.haerstedt@limesurvey.org (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) ------=_Part_1041287_1840044666.1625061541733 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable https://github.com/LimeSurvey/LimeSurvey---- On Wed, 30 Jun 2021 14:22:46 += 0200 Olle H=C3=A4rstedt wrote ---- ---------- Forwarded message --------- From: Larry Garfield Date: Tue, 29 Jun 2021, 20:05 Subject: Re: [PHP-DEV] [Vote] Partial Function Application To: php internals On Tue, Jun 29, 2021, at 1:00 PM, Larry Garfield wrote: > On Tue, Jun 29, 2021, at 12:30 PM, Guilliam Xavier wrote: > > (Extracted from the "Pipe Operator, take 2" thread) > >=20 > > On Tue, Jun 29, 2021 at 12:54 AM Larry Garfield > > wrote: > >=20 > > > On Mon, Jun 28, 2021, at 5:30 PM, Olle H=C3=A4rstedt wrote: > > > > > > > Would a slimmed down version have more support? How about removing= the > > > > variadic operator, and let the user manually add the lambda for th= ose > > > > cases? > > > > > > I talked with Joe about this, and the answer is no.=C2=A0 Most of th= e > > > complexity comes from the initial "this is a function call, oops no,= it's a > > > partial call so we switch to doing that instead", which ends up inte= racting > > > with the engine in a lot of different places. > > > > >=20 > > Are you saying that the implementation complexity is mainly due to cho= sing > > a syntax that looks like a function call? > > If yes, is it also the case for the "First-class callable syntax" RFC? > > And does it mean that a different syntax (e.g. with a prefix operator) > > would result in a simpler implementation? >=20 > From what I understand from Joe, most of the complexity comes from=20 > producing something that isn't a closure but shares the same interface= =20 > as a closure (at least that's what it would be in PHP terms), which=20 > then requires lots of special handling throughout the engine.=C2=A0 I do= n't=20 > fully understand it all myself, TBH. >=20 > I've been pondering if a completely different approach with a prefix=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 send= , of course).=C2=A0 Quoting Joe: =20 "the engine expects certain things to happen, and is designed and then opt= imized around those assumptions ... for example, a stream of INIT, SEND, DO= _FCALL is not meant to be interrupted, the first fundamental change you hav= e to make is making the engine aware that stream of INIT, SEND, + are not a= lways followed by DO_FCALL " =20 So yes, it sounds like hooking into the function call process is where the= complexity comes from.=C2=A0 Which suggests that an approach that works us= ing a different syntax that desugars to a closure would avoid that issue, b= ut then we need a syntax that wouldn't be ambiguous, and that's getting har= der and harder to find.=C2=A0 (Nikita's first-class-callables RFC notes som= e of the issues with available symbols, and they're essentially the same fo= r partials either way.)=C2=A0 And I've been told that creating closures in = the AST compiler is Hard(tm)... =20 --Larry Garfield Wrapping stuff in lambdas is otherwise the obvious solution, no? Make `strl= en(?)` evaluate to `fn ($x) =3D> strlen($x)`. Does it depend on the level o= f look-ahead in the compiler why it's so hard? Didn't work much with script= ing language internals. Olle ------=_Part_1041287_1840044666.1625061541733--