Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115334 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 8898 invoked from network); 6 Jul 2021 22:55:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Jul 2021 22:55:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 556411804B0 for ; Tue, 6 Jul 2021 16:16: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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.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 ; Tue, 6 Jul 2021 16:16:54 -0700 (PDT) Received: by mail-ot1-f42.google.com with SMTP id d27-20020a05683018fbb02904ae64d1b56bso433621otf.9 for ; Tue, 06 Jul 2021 16:16:54 -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=DeY8WMV4uH75DI2RS2YRem5+JScarqZoFdzpDu1IxwI=; b=lm1rcjY0e/NMEuTIXLcmmUUaTcd1W+vlmFtN+sMUwd3uvC7AGjz8N/NXlMdkCvnGO0 3tWK4OCCc2qWoRrwrt0dPCVJSMBRMvvPjTcM5u9UN6H0oSwqQoRZYzCVramjVwMrYE1C Htw3AHq0DZhQuo6+1+h1mauJcBGv/33C5Di2BRFPnS9k6rK0Mn1r4OOccTXsYqO1vgMr jmVE3joMTA3oLlYkWBbHYCrlEt6tWmwzhYRIM3EYmjlvSUr6Q8Z9fkfbFh0nc1OGhqtW iuxQ7TqRYvXXdzbCwRtQPhOCC4dUNKbVGOz65IgRs444lX3XYOCja0IF1aJCJmryvCTJ VSaA== 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=DeY8WMV4uH75DI2RS2YRem5+JScarqZoFdzpDu1IxwI=; b=kCt0UGGCyLaklkBWXxPbwoDh82b6D9Xj6R7gkmoMEyNmOuAUnbBueZirpsIUt69zRy zaph48GbJcidyvqSjGbC7QagY+R+4V50p8ojIXDuDq3Pp1uye8UvbARH1f87nGkUXMcl s/GeIefM9vY7fEhaaof+tIQlGyH+2uIB6863DfBp6yDM1eXcgWKSaYcw1pE5Xskehpzx hsYzf7fJbyEhfJ4x7rKME54B5mkadbKm5iYPfU5QMeluK2D5AUi057ANTQn4UdOtSVXm qFnGjy6Wj/UAo6nrN2zvJ5BraV5ZVO3hhDs7Fs4/c3fYHqH6E5TkwGMw+7bhY5dPxnil Z2KA== X-Gm-Message-State: AOAM532hEyHt/yBuToepYlUjPUkYaeqhneGbrV1p9KtyOHDHPSLVL/Gh 8OQlHPA9xWoRpvFnQs3RsUMQWyyXcptP+d3trlwBXH/8 X-Google-Smtp-Source: ABdhPJyEi9AfKxYtdpcEeYEXWSMgA+jEHgZw5e95dCXzdZnswd4JaYOMXkwHwLUl/rRIUKdnbhIxzu1IAYjmTJcdMbE= X-Received: by 2002:a9d:39e3:: with SMTP id y90mr17249672otb.257.1625613413466; Tue, 06 Jul 2021 16:16:53 -0700 (PDT) MIME-Version: 1.0 References: <63aa426c-30bc-4f00-8740-532fa0bef6f2@www.fastmail.com> <48bc0d19-ba92-4dbf-b2d4-a32688ed4e25@www.fastmail.com> In-Reply-To: Date: Wed, 7 Jul 2021 01:16:42 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000000d44a205c67c9e2c" Subject: Re: [PHP-DEV] [RFC] Pipe Operator, take 2 From: krakjoe@gmail.com (Joe Watkins) --0000000000000d44a205c67c9e2c Content-Type: text/plain; charset="UTF-8" Just to clarify, I said it didn't look like it could be a pure AST implementation, and that it looks like you may need one additional instruction. It does look that way to me - if only to throw a sensible error specifically for pipes but also because it makes the imposition of specific behaviour for pipes a little easier, but it doesn't make it a super complicated thing. I also said I didn't know what the right answer was with regard to refs. I still don't, although I lean towards blocking them at the moment having spent a little more time looking at it. I don't really think we've had long enough to have this conversation properly. Cheers Joe On Tue, 6 Jul 2021 at 19:05, Larry Garfield wrote: > On Mon, Jul 5, 2021, at 11:05 AM, Larry Garfield wrote: > > On Sat, Jul 3, 2021, at 9:12 PM, Larry Garfield wrote: > > > On Mon, Jun 7, 2021, at 2:00 PM, Larry Garfield wrote: > > > > Hi folks. Me again. > > > > > > > > A year ago, I posted an RFC for a pipe operator, |>, aka function > > > > concatenation. At the time, the main thrust of the feedback was > "cool, > > > > like, but we need partial function application first so that the > syntax > > > > for callables isn't so crappy." > > > > > > > > The PFA RFC is winding down now and is looking quite good, so it's > time > > > > to revisit pipes. > > > > > > > > https://wiki.php.net/rfc/pipe-operator-v2 > > > > > > > > Nothing radical has changed in the proposal since last year. I have > > > > updated it against the latest master. I also updated the RFC to use > > > > more examples that assume PFA, as the result is legit much nicer. i > > > > also tested it locally with a combined partials-and-pipes branch to > > > > make sure they play nicely together, and they do. (Yay!) Assuming > PFA > > > > passes I will include those tests in the pipes branch before this > one > > > > goes to a vote. > > > > > > Hi again. > > > > > > With PFA being declined, I've again reworked the Pipes RFC. > > > > > > 1) It now does not use PFA in any examples, but it does use Nikita's > > > first-class-callables RFC that looks like it's going to pass easily. > > > > > > 2) With major hand-holding from Levi Morrison and Joe Watkins, the > > > implementation has shifted a bit. It now evaluates left-to-right, > > > always, whereas the previous version evaluated right-to-left. That > is, > > > instead of $a |> $b |> $c desugaring into $c($b($a)), it now becomes > > > effectively $tmp = $a; $tmp = $b($tmp); $tmp = $c($tmp); That matters > > > if $b or $c are function calls that return a callable, as they are > then > > > only called when the pipeline gets to that part of the expression. > (If > > > all the functions involved are pure functions, then it doesn't make a > > > difference in practice.) > > > > > > 3) I included references to several existing PHP libraries that > > > implement similar logic, in mostly complex and ugly ways. > > > > > > 4) Of note, Brent posted a Twitter poll last week about pipes, and the > > > response was overwhelmingly in favor. > > > (https://twitter.com/brendt_gd/status/1408271132650885123) Naturally > a > > > Twitter poll is extremely unscientific, but I think between the > > > existing libraries and the response there the answer to the question > > > "is there actually a demand for this feature?" is unquestionably yes. > > > > > > 5) Examples have been reworked to be a bit prettier. > > > > > > 6) Added another language reference that has a pipe operator that > works > > > basically like described here. (OCaml) > > > > > > I am planning to take this version of the RFC to a vote on Monday or > > > Tuesday, as Tuesday is the last day possible to start a vote for 8.1 > > > features. > > > > > > --Larry Garfield > > > > Based on feedback on the PR, I've updated the RFC to forbid functions > > that pass or return by reference. They're not really useful in pipes > > at all, and were only supported before because the implementation > > happened to allow it. > > > > The PR hasn't been updated for that yet, but I figure that's easy > > enough to update post-vote if it passes. > > Sorry for the noise, but after some discussion with Joe it looks like > blocking references in pipes is actually much harder than it sounded like, > and would require a completely opcode based implementation rather than the > completely AST-based implementation. References on pipes are not really > useful but in practice they don't hurt anything. I've instead added more > tests to validate that they behave "as expected" and noted that in the RFC > instead. > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --0000000000000d44a205c67c9e2c--