Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115246 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 960 invoked from network); 1 Jul 2021 06:34:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Jul 2021 06:34:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AD7881804C3 for ; Wed, 30 Jun 2021 23:54:32 -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,FREEMAIL_FROM, 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 mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 23:54:32 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id u25so6891729ljj.11 for ; Wed, 30 Jun 2021 23:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=hy2Fn3wuRrjPif1DtdfNF5+ozRDkw/DOHCbJUr+JUCk=; b=P0VKAC54qwK+rld/uLZ5U6yLSrwRbScal+S2Sq7nadCs6HR+/EFH8boMAb+NlCAGVE M7/u63sLizmpLq4GPbDwR5hE1ah/ARP4wbDkYQww8onY03SjzEwDtkmB9SrteVln92xJ dhDpxdiaUvFCg/R0PaJ7g9N4Y+6wL73il2iGE0+XtpobOXUHrGRudbwjsgeUilpo4Ba2 kBcsya4/NatZDQ3AT3w1RdVRyCinXq5qdTTyJC+D31iPCuooB9iYLT2mJ4zlLozYlplA 0ksiUItmZiFt9ml33waBlHinMi0Iqa/lQd8cjTv6H03CVymqGdjnTGxqGk9TcAaf6HQ+ kVng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=hy2Fn3wuRrjPif1DtdfNF5+ozRDkw/DOHCbJUr+JUCk=; b=R74TZ960ZMceOdd2bvV2oB7ILYbYpRVQycv/gSFmWX1Y8tEYxc1oNXy5WUcoVfQT1F HO42Il6pw+cK3UWp5Kesd9JvnTT7QuGVL60wg3vnckeEDk+Lc12PcwEcJqJGs2v6F7gi h7ALoEnn1uG6Icb8WzDziN+MV5jdVmkl9iif/X0MlOuLc8YLwoopatovb64heTO1mZIJ Uw6cIc1Zpja+4NDcIXc0nPSHWK88Sy83O4meTUY3wzqxoMr3qIES/rSBpNedYJdD9MLT BW/McQlahL8YxMvdquUOBTwFrkytwO7aX3d66vib6IM45btv2pDK1tYA5n9z+Rx842XP ipkw== X-Gm-Message-State: AOAM533oGwBzRMrM1BubmPbhX6hwpqlFbHDLW+tEgUFnwLgC8UH+eYf/ EcLgq8w7YggzqcVAm2KXDVP5iOKR2LwzZPV4tewRFfnB X-Google-Smtp-Source: ABdhPJzSE8dNQDXdiv4dJ6f1FafkUX5q5j5Aoj5c0CcopLMF8s/qnSEiXTe68SeFUkepF5cabXlrdPiRHK6Ly45odhg= X-Received: by 2002:a2e:a288:: with SMTP id k8mr10363284lja.367.1625122467145; Wed, 30 Jun 2021 23:54:27 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:7506:0:0:0:0:0 with HTTP; Wed, 30 Jun 2021 23:54:26 -0700 (PDT) In-Reply-To: <8e6ad5a6-f627-4e3f-af04-6384ab6147f0@www.fastmail.com> References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> <9f0c9565-22e1-4d94-bef5-cfc44ce02dc5@www.fastmail.com> <17a5d374765.1289062a2301127.8166821672739325531@limesurvey.org> <8e6ad5a6-f627-4e3f-af04-6384ab6147f0@www.fastmail.com> Date: Thu, 1 Jul 2021 08:54:26 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [Vote] Partial Function Application From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) 2021-06-30 19:10 GMT+02:00, 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 prefix >> > symbol would be able to be less complex, and the simple answer is I >> > have absolutely no idea. But we are running low on symbols... >> >> Ah, I found the technical details that Joe gave me (right after I hit >> send, of course). Quoting Joe: >> >> "the engine expects certain things to happen, and is designed and then >> optimized around those assumptions ... for example, a stream of INIT, >> SEND, DO_FCALL is not meant to be interrupted, the first fundamental >> change you have to make is making the engine aware that stream of INIT, >> SEND, + are not always followed by DO_FCALL " >> >> So yes, it sounds like hooking into the function call process is where >> the complexity comes from. Which suggests that an approach that works >> using a different syntax that desugars to a closure would avoid that >> issue, but then we need a syntax that wouldn't be ambiguous, and that's >> getting harder and harder to find. (Nikita's first-class-callables RFC >> notes some of the issues with available symbols, and they're >> essentially the same for partials either way.) And I've been told that >> creating closures in the AST compiler is Hard(tm)... >> >> --Larry Garfield >> >> >> Wrapping stuff in lambdas is otherwise the obvious solution, no? Make >> `strlen(?)` evaluate to `fn ($x) =3D> strlen($x)`. Does it depend on the >> level of look-ahead in the compiler why it's so hard? Didn't work much >> with scripting language internals. >> >> Olle > > The tricky part is that conversion has to happen entirely at runtime, > because we need the type information from the function being partialed, a= nd > 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 much > easier. > > We've been discussing this for the past several days in chat, and the bas= ic > 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 approach. So = far > no one has figured out a not hard-and-messy way to make it work, regardle= ss > of performance. > > --Larry Garfield Alright, alright. Guess I have to learn a bit more about the different passes inside the compiler. :) Thanks. Olle