Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115225 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 96367 invoked from network); 30 Jun 2021 07:57:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Jun 2021 07:57:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 03FE61804C3 for ; Wed, 30 Jun 2021 01:18:10 -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,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 mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 01:18:09 -0700 (PDT) Received: by mail-lf1-f42.google.com with SMTP id w19so3547803lfk.5 for ; Wed, 30 Jun 2021 01:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Fn7CkH4/8SCqV/6gMrGeSBD5tTBO+WKMLPhvMFaTMEI=; b=dCeXp7Ct04c3joYfTcb53hMvodOG3IlvbJD5iSAZwSiNyYwGq6AF+FHbuMWiOi/okn mRFGP/fEeyjj9uXsVG6Bd5mnjN/v5my2xlu/gTGCQL54k73YTHsxz95LdqRG2HTBaYbQ JbfBN7fD0V8EXiESL2McN6KWP80R2YnnNBW+UNMREIgjJtx4YsR1mPr3gc/eyV8JjiSe sJb25xP4mUyxuVtMOsutHbZtGXwGz3vSiAIoyyXwgj6sV6xYQhbnoS5m7BgCJLyGeeuK +V3bDXB/LoF6RXe+PbIhPNCOTldiE/V3ziZDE4kY7R8uHipVNKdzvbTbUHe6aUSoBkXp tUGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Fn7CkH4/8SCqV/6gMrGeSBD5tTBO+WKMLPhvMFaTMEI=; b=LcutLqF9GVypKrmUI07Rzt8nbNgSpMES2l/dIsH08yaqaNZDu3FSK8U+oIk+8iJVES j/pzJMKFUN9DSuOCINYlZVe09Ue2qMxsXQ2Jvx3oKk/u+Wu/tQLq2cKO8mp6D/qTLeMh mlvhO2akVckCC/GvDCb+HF+foXr/nmMFcuz/av7CDDprkzyNY7W+Xl3fJh3agd4P4baX FU5hW8RPMpOAdWaaD71uFgpKqGsgQMOro0qMA9TyHRDg/PeZvGuN+hpm+2SognCQ1G0k FuuWoP+HCgF3C5UcnYkZd4hVmWE+TUv+zm7xVk9r54AjVTp1o6gzZswlBuQV5dFj236g ntiw== X-Gm-Message-State: AOAM531BElHUfDY1oaPnKUzZkU7hByyAKB264Q546pi+lYvIkQd8SBXc epT7874k0SCwiKuOnORiU+V8x3EAlvicF+JfQ581uBeOJ+Mi X-Google-Smtp-Source: ABdhPJwUp18XoEo8iqWa/eb3QJMDdUSPmEKi+KXaO8jb7RrwR/5878KlcVd48MbPd0bp/40IjS8AZFD8WXybML6uFV0= X-Received: by 2002:ac2:5a04:: with SMTP id q4mr479653lfn.110.1625041086348; Wed, 30 Jun 2021 01:18:06 -0700 (PDT) MIME-Version: 1.0 References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> <9f0c9565-22e1-4d94-bef5-cfc44ce02dc5@www.fastmail.com> In-Reply-To: Date: Wed, 30 Jun 2021 10:17:54 +0200 Message-ID: To: php internals Content-Type: multipart/alternative; boundary="000000000000b27ffa05c5f75c6e" Subject: Re: [PHP-DEV] [Vote] Partial Function Application From: guilliam.xavier@gmail.com (Guilliam Xavier) --000000000000b27ffa05c5f75c6e Content-Type: text/plain; charset="UTF-8" On Tue, Jun 29, 2021 at 10:32 PM Levi Morrison via internals < internals@lists.php.net> wrote: > On Tue, Jun 29, 2021 at 12:05 PM Larry Garfield > wrote: > > > > 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) > > > > > > > > On Tue, Jun 29, 2021 at 12:54 AM Larry Garfield < > larry@garfieldtech.com> > > > > wrote: > > > > > > > > > [...] Most of the > > > > > 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 > interacting > > > > > with the engine in a lot of different places. [...] > > > > > > > > Are you saying that the implementation complexity is mainly due to > chosing > > > > a syntax that looks like a function call? [...] > > > > > > From what I understand from Joe, most of the complexity comes from > > > producing something that isn't a closure but shares the same interface > > > as a closure (at least that's what it would be in PHP terms), which > > > then requires lots of special handling throughout the engine. I don't > > > fully understand it all myself, TBH. > > > > > > 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)... > > Based on what you said, the syntax isn't really the issue. Rather, the > issue is assumptions about how function calls work at the opcode > level. Any implementation of only _partially_ doing a function call > will have to deal with such things in some form. To a degree this is > inherent complexity. > Thanks for clarifications. IIUC, whatever the syntax, any PFA implementation will need either to hook into the function call process (current approach) or to create a closure "from scratch" (which may be actually more complex); and some degree of [implementation] complexity is conceptually inherent anyway. (FCC doesn't need to bind values so might have other options? maybe not...) > Maybe separate opcodes for every piece of the call would be better in > that optimizers, etc, won't have expectations around the new opcodes > and we don't change assumptions about the existing opcodes? I doubt > that it would be much simpler, but I am curious to know. > -- Guilliam Xavier --000000000000b27ffa05c5f75c6e--