Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120843 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71712 invoked from network); 18 Jul 2023 17:08:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jul 2023 17:08:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 858B01804DF for ; Tue, 18 Jul 2023 10:08:57 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 18 Jul 2023 10:08:57 -0700 (PDT) Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-57a4c0324b5so7645127b3.0 for ; Tue, 18 Jul 2023 10:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=negyesi-net.20221208.gappssmtp.com; s=20221208; t=1689700136; x=1692292136; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OrXRcZ+e/AOG8oUVu+nqVfj/PGk/JVJA59VeKyY6XvU=; b=JHViTQyubDzJGQJoF448yD9UlaafTOpPAVg1VYOZJ9BU7xIW3YpKw3oqacKMiS/B8V qrA7QE8HDbDvMsy78EG6dVJacy2nugui7yrez+EFvAW6aGUUKbptBrJbo+p9gLK3+y/9 6rBVu7Wm6zUA+8cHuaVqwZubMY4tOuZJfLxRuY0Qd8QfdfXENNsPpX9vgLVm55Fvq5qh JF+1P35yQnS3DzTh3toXjCOTozfK9w414KwSe5GVgmHnI4IJfBQ8zXn4CFtg/duOhO8w p9k+AslLJAyZ+MxZVZKxCgXhEsAZ9m/TGalFe1r/5tgh00gvzzxyvEx7Tbhjo5Z9g8OZ MvEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689700136; x=1692292136; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OrXRcZ+e/AOG8oUVu+nqVfj/PGk/JVJA59VeKyY6XvU=; b=enioWnpIF0IoKI+AhHKyvgaOUFl8cQTVAC/flafV3LUZ1M33nsjw0qa7o0RzMnzUmZ 9hnejiHC2d9M1lfD0M91olf+4ZJ6DOkdYyhx7+DczT+PF+eSWz/2ON5JsxDy4VX2pr2y WdipWckXbvugncq58GQb2X6nu3WGytNhB1nvunFKZ9vY4XTn+YsIiOYi7D2P7H59oqj+ xpEwD3hvh4QjyMMPOjbvlD+FH3B2Yv00CcUvDrn0Fmc7UF96Gojb5KZXbPV8xlesNTbF ObelqL9RtmWWcFlpvQkf5yf5QoEK1lJIyMM2DVpdbUQMyiJBWTducZgpX0Li+TNsNIdA edvw== X-Gm-Message-State: ABy/qLaOJ6CQQXQOLW+JagI+Qt9eZtvSTak9/LNezeNtzXDhYrMQBwXv 6myIfBez4zFy179iEpJdw1rgDkEfdWNy1lr4+UE= X-Google-Smtp-Source: APBJJlGsOhiYVbvqFdX99sGuCWnf5ffdJIaOetDiy3yAUn3uitlatZygjdHIiBu+VahWwAMNaweXqA== X-Received: by 2002:a0d:dd4a:0:b0:565:5228:44f7 with SMTP id g71-20020a0ddd4a000000b00565522844f7mr295457ywe.4.1689700136005; Tue, 18 Jul 2023 10:08:56 -0700 (PDT) Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com. [209.85.219.180]) by smtp.gmail.com with ESMTPSA id y129-20020a0dd687000000b0056d4b5cde00sm556578ywd.118.2023.07.18.10.08.55 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jul 2023 10:08:55 -0700 (PDT) Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-c2cf4e61bc6so6283567276.3 for ; Tue, 18 Jul 2023 10:08:55 -0700 (PDT) X-Received: by 2002:a25:6954:0:b0:ce8:cd8d:f0db with SMTP id e81-20020a256954000000b00ce8cd8df0dbmr479508ybc.28.1689700135291; Tue, 18 Jul 2023 10:08:55 -0700 (PDT) MIME-Version: 1.0 References: <8055b366-32f1-4d2c-85d0-0cf665e6c8d3@app.fastmail.com> In-Reply-To: Date: Tue, 18 Jul 2023 19:08:43 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Larry Garfield Cc: =?UTF-8?Q?Olle_H=C3=A4rstedt?= , php internals Content-Type: multipart/alternative; boundary="0000000000005753720600c5f895" Subject: Re: [PHP-DEV] pipes, scalar objects and on? From: karoly@negyesi.net (Karoly Negyesi) --0000000000005753720600c5f895 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable My favorite pipeline is Elixir, where "The pipe operator |> passes the result of an expression as the first parameter of another expression".. But it works there because unlike with PHP, it's almost always the first argument you want. If it's not the first argument you needed to do some tricks which was only cleaned up in 2021 so now they do: 5 |> then(&Enum.take(1..10, &1)) |> Enum.reverse() but I digress. My problem here is... we actually need something that passes the RFC vote. What flexibility is missing here? On Tue, Jul 18, 2023 at 6:48=E2=80=AFPM Larry Garfield wrote: > On Tue, Jul 18, 2023, at 4:41 PM, Karoly Negyesi wrote: > > So. Let's get back to pipelines. > > > > I wrote this email because I was manipulating a robots meta tag string: > > > > $robots_array =3D explode(', ', $robots_string); > > $robots_array =3D array_diff($robots_array, $remove); > > $robots_string =3D implode(', ', $robots_array); > > > > Very pipeline-ish. > > > > You could write a userspace pipeline > > https://gist.github.com/chx/6638aba76d8b414ffedc7e5af78fb479 but this > has > > the advantage of being spectacularly ugly and slow as well. > > > > Just converting it into a pipeline with > > > > $robots_string > > |> fn ($x) =3D> explode(', ', $x) > > |> fn ($x) =3D> array_diff($x, $remove) > > |> fn ($x) =3D> implode(', ', $x) > > > > has the same characteristics. What I would love to see: > > > > $robots_string > > |> explode(', ', $) > > |> array_diff($, $remove) > > |> implode(', ', $) > > > > While that does look like partial function application, it does not nee= d > to > > be. It could be just syntactic sugar. Namely, in the expression followi= ng > > |> a $ is replaced by the entire expression before the |>. Step by step= : > > > > explode(', ', $robots_string) > > |> array_diff($, $remove) > > |> implode(', ', $) > > > > array_diff(explode(', ', $robots_string), $remove) > > |> implode(', ', $) > > > > implode(', ', array_diff(explode(', ', $robots_string), $remove)) > > > > We could use any other symbol but I liked the $ sign here because the > > entire point is not needing a temporary variable between steps so the $ > > sign stands for "unnamed temporary variable". I also believe it can't > lead > > to any ambiguous situation (famous last words). > > > > What do you think of this simple version? > > That's what Hack does, and what no other language does. I dislike it as > it's actually much less flexible overall. It's also more work to impleme= nt. > > The original idea was that combining real PFA with a callable-based pipe > would give us the same net effect if we wanted it, but with greater > flexibility and more power across the whole language. Unfortunately the > PFA RFC barely didn't pass, due to its complexity. A nicer implementatio= n, > if it could be found, would probably pass. > > --Larry Garfield > --0000000000005753720600c5f895--