Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109905 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24344 invoked from network); 29 Apr 2020 09:11:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Apr 2020 09:11:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 86AE21804C2 for ; Wed, 29 Apr 2020 00:45:07 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (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, 29 Apr 2020 00:45:06 -0700 (PDT) Received: by mail-lf1-f68.google.com with SMTP id d25so796325lfi.11 for ; Wed, 29 Apr 2020 00:45:06 -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 :cc; bh=yzl6G/+zyOLgYgv7xriMbJI7gaAl0oKH3jLgk0fQWAg=; b=rn0nJPynkCQOCwm4+8IZ9eYKIg/TMu/J4kWH6iBkHHY+UrUtK18QI4FfcG96hOLpMt n/Aaj6NFvlg82XrTtt6D18FWSwV736EEKdGUTlm1e8wbGOn3Bz4k1S+mBIkwR3Fljrbz xb1a5OUngod/+Bv6mcR1empcYbBQphablcta9wrACSYJ/ej9n7KQBxZ7gIdeTOt/G1Qy pKoldjwGOebtOhFHZBptNdgdvypJq1BO0VBRGJTAXWm8WT3gnZ6S8V86pXIX6zqg9agK UaCM1AigL2cGS5y4xhZsygKzH46k5SJeV/vQdBQKM9n8uOmtq5K1krDQvFLCSaQi8a6q kW1A== 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; bh=yzl6G/+zyOLgYgv7xriMbJI7gaAl0oKH3jLgk0fQWAg=; b=Doxm7o8AhvYbfLcZOMBwsFUFrhVrei1FNzsfR5ueVgIKe/SHtsRTGrCcwugq9jjLIm 5M5WFqFEhc3JkAwNrpPyiVQIwS+ziXjhIi2n+FZPPLa5yEgcjD/bMoktMi0xonzsgE/w 7WHFSfIH3gcxbaRsgAZaaZMdEmOn13rPKgkSJFGUns70ZoXuJa+lZEGw4Y7tAJlrFzIM KVOnTGFpFmb2ZPKEE2S1CTzGxROfejsydRiPE7/6e4t3fE/vfLBoWMX0ThX9teQXGnir krTJESUfAgiGIIyxULcOY7VEqC8jBTPLlOIz6TmwMyBWpac9QtfpjM2M3/f+UWD1IPT4 v3wQ== X-Gm-Message-State: AGi0PubS9/nhfq0yBO9UpNnIhUjZMyYmpikDoyncPTRvTQqGDWuoLwwI 5tZo/pm9zdx85/cPijuX9R1W6DD2rANEgTa3PXw= X-Google-Smtp-Source: APiQypKSqy5XPHiof2nQPp7pd+y6kmnxhKpTJHJNj5fkpoMu/1cz+B6Dvy52z7hDQxGGVHlE0u3MC6N2ybLT9W82MkM= X-Received: by 2002:a19:c7d8:: with SMTP id x207mr21451803lff.190.1588146303099; Wed, 29 Apr 2020 00:45:03 -0700 (PDT) MIME-Version: 1.0 References: <2677cdc6-309c-4e4e-9cd9-12ff2a90c1e1@www.fastmail.com> <93A509E9-E6BC-425C-A584-F49F094E75B0@benramsey.com> <46adaf3a-be5b-4eaf-b2fd-7243d00200e1@www.fastmail.com> In-Reply-To: <46adaf3a-be5b-4eaf-b2fd-7243d00200e1@www.fastmail.com> Date: Wed, 29 Apr 2020 09:44:47 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000003f665a05a4692020" Subject: Re: [PHP-DEV] [RFC] Function pipe operator From: nikita.ppv@gmail.com (Nikita Popov) --0000000000003f665a05a4692020 Content-Type: text/plain; charset="UTF-8" On Wed, Apr 29, 2020 at 2:35 AM Larry Garfield wrote: > On Tue, Apr 21, 2020, at 9:43 AM, Larry Garfield wrote: > > > On Mon, Apr 20, 2020, at 11:06 PM, Sara Golemon wrote: > > > Happy with the revival, and I do want to underline the "Future Work" > > > section about Partial Functions. PF will make this version of pipes > 100% > > > more readable and fluent, and I want to endorse both, but I'll take > one at > > > a time. > > > > I agree that the pipe operator relies on having a "good" (subjective) > > way to reference callables, which is a weakness of PHP right now. We > > discussed that in depth a few months ago as well. > > > > IMO, short-lambdas in 7.4 are "good enough" to make the pipe operator > > useful. They're not ideal, but they're sufficient. > > > > Levi's partial application RFC would be close enough to ideal; You > > could reference an already-single-parameter or multi-parameter function > > lexically without any string parsing silliness, which means namespace > > resolution works, and it could potentially be optimized to avoid an > > extra layer of function call. It would be even better than ::function, > > IMO, because you can provide it with closed-over variables at the same > > time. It sounds like we all want that. > > > > I do not believe that should block the pipe operator, however. This is > > a case where two independent RFCs should be able to stand on their own > > but create a "sum is greater than their parts" situation, which is a > > good thing. > > > > If anyone has bandwidth, I'm happy to collaborate on the PF RFC as > > well. It's out of my solo skillset right now (frankly so was pipe > > until this weekend), but if someone is able to provide > > hand-holding/pairing I'm willing to work on that, too, either now in > > parallel or after pipe lands. Both should happen, but I don't think > > either should block the other. > > Just an update: I've tweaked the patch based on feedback from a few > folks. The precedence now seems to be where it is most logical (to me), > and I've changed what the flag is on the AST node based on a recommendation > from Nikita (assuming I understood him correctly). I think it's in an > acceptable final state at the moment baring any further feedback on GitHub. > > It sounds like the only negative pushback at the moment is "can we do > partial application first?" Which... I'd love to but we need help on that. > :-) (Volunteers welcome.) Is there any other pushback? > > How do people feel about putting this to a vote sometime next week? I > don't know how long I want to sit on it waiting to see if we can pull off > partial application. I also want the partial application RFC, for reasons > stated, but still feel that both are beneficial enough to stand on their > own and it doesn't really matter which happens first. > I think it's pretty unlikely that this RFC will pass without having partial application first. I understand that the features are technically orthogonal, but in terms of coding style, none of the examples given in the RFC would pass code review (from me). They either use PHP's ugly callable syntax, or they use arrow functions, in which case you could just as well store the value in a temporary $x, rather than using an fn($x) function combined with the pipe operator. As-is, I don't think the pipe operator would constitute an improvement over the status quo. So... feel free to start voting, but don't get expectations too high ;) Small note on the RFC text: The line |> fn($x) => array_map(fn($v) => 'strtoupper', $x) should probably be just |> fn($x) => array_map('strtoupper', $x) Regards, Nikita --0000000000003f665a05a4692020--