Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115221 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53624 invoked from network); 29 Jun 2021 20:11:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Jun 2021 20:11:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 61B3A1804B3 for ; Tue, 29 Jun 2021 13:31:55 -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,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-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (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 ; Tue, 29 Jun 2021 13:31:54 -0700 (PDT) Received: by mail-yb1-f169.google.com with SMTP id c8so1079264ybq.1 for ; Tue, 29 Jun 2021 13:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=BeA0xMhxdnILtt3I4iiry+mhw1THrcNXuy5zz+9dNzQ=; b=PjYo2lPohZdu28+cMlVPpzJTmmr2iqo7k730ejcWBv57w/JuQLX6g3OOTh1VRXjoAg i4srXn1kfoBjEBUcs6Gx8NdjilbHWcwajfkMqRE2U5g+jIcfYQKh40Gy2e/sFUEmwIsT 4nanEFFe1KHlHgX/Fw45PlkcYMkEs/p+c9VIE= 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:cc:content-transfer-encoding; bh=BeA0xMhxdnILtt3I4iiry+mhw1THrcNXuy5zz+9dNzQ=; b=SkiebdlvPBJleJlijJ7jIgkUF1SOrRIpZPQbzfkiqL9bwOfFzeEkAmZCIYyUqTlQnr /QkO/ms3a667GXeZRk4nxMh0B6l4TB7UatZqThKK3Gb2h9e2whDWbKrwt33kbIrkvPn+ egEVqPdfNGVALEU3iy14OiMOX3apK4WnqQQxvLrCe1sIKFg0Wl+iClc2qTy6tlroTi+S CLOFmXs6VJp+P3duvUBb8/8nF44jGOeOs7IDMAOceLc46EV646bYfFIe0FF//TE+vI+V blM8YDgGN+mxOq+fGC6b1C5STrjxzkC8YB3mRda1znJT/jYk727rX2cPpXbAeP7MY7hu y4Ew== X-Gm-Message-State: AOAM530J8qgoSVZNO5+xbyuBBtSkR27vLhDyqQm10rQmntsAOmu14QKu 0VMPV30hxWshqfpKJ5gDyAY1gJgR5c6AjfZ58cOCeBJbf3Y= X-Google-Smtp-Source: ABdhPJwegOb5VOJqYl8jXsFsu8WqhsXLXDctk6z9BZI+UPkVfJWtWsawnu95U1mlgNynMcdYUB15AgsaRqGcCtOETUE= X-Received: by 2002:a25:cec4:: with SMTP id x187mr12982094ybe.402.1624998711608; Tue, 29 Jun 2021 13:31:51 -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: <9f0c9565-22e1-4d94-bef5-cfc44ce02dc5@www.fastmail.com> Reply-To: Levi Morrison Date: Tue, 29 Jun 2021 14:31:41 -0600 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: internals@lists.php.net ("Levi Morrison via internals") On Tue, Jun 29, 2021 at 12:05 PM Larry Garfield wr= ote: > > 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 > > > wrote: > > > > > > > On Mon, Jun 28, 2021, at 5:30 PM, Olle H=C3=A4rstedt wrote: > > > > > > > > > Would a slimmed down version have more support? How about removin= g the > > > > > variadic operator, and let the user manually add the lambda for t= hose > > > > > cases? > > > > > > > > I talked with Joe about this, and the answer is no. 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 int= eracting > > > > with the engine in a lot of different places. > > > > > > > > > > Are you saying that the implementation complexity is mainly due to ch= osing > > > 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? > > > > 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 sen= d, of course). Quoting Joe: > > "the engine expects certain things to happen, and is designed and then op= timized around those assumptions ... for example, a stream of INIT, SEND, D= O_FCALL is not meant to be interrupted, the first fundamental change you ha= ve 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 th= e complexity comes from. Which suggests that an approach that works using = a different syntax that desugars to a closure would avoid that issue, but t= hen 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 partial= s either way.) And I've been told that creating closures in the AST compil= er is Hard(tm)... > > --Larry Garfield 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. 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.