Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115187 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20103 invoked from network); 28 Jun 2021 19:05:42 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Jun 2021 19:05:42 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3992D1804C3 for ; Mon, 28 Jun 2021 12:25:31 -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, 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-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.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 ; Mon, 28 Jun 2021 12:25:30 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id a6so3461529ljq.3 for ; Mon, 28 Jun 2021 12:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=MpkzKYpNrVgg79MOC7RksYzwafcHHGIpsDBCvH5wRqA=; b=rnPLZ5UTr/csAUqlyeMRahh3LS9gegPnBhMFot6EmdlDAUHq0SQ2O1Ynm9mEtDegpL zCt/KiU4TFgMpS5waM5BTRpUk4pvsZm53o7hxhU0Mgg+H6HN6WSl9/YPVQxF8Va1qpWg Jr0dS9GkEU9lb0WHPgDielDIIy0S51lNU7oMY72zUpkqjmPInKSqzX9szgJwVL9d/yuZ qfVlEQisCQtoVq36SGcraTG72prbS9w4SjR0diiBJs3CJrp8iGS5hUYoRBQvsvy8Qkeb 7Vnw2JVrCON6zGSHmKiJr6hBORiiLj9KR7VT5GBX7SXDVUkru2L64PLOtVOU25T4EAS3 Q0hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=MpkzKYpNrVgg79MOC7RksYzwafcHHGIpsDBCvH5wRqA=; b=SykBCSGoYsERAbnLHQ9e2qs9EgNJACwuJgKeSz1Tn9jHHCK8MgkUuBKTi/SQnYvcGA 46RWwZFGO5wOXAPce9lobi3Dh1qFH+z2Ht2j84oP3WVWKvKFJnzWdwMiE4YUX1WJ/MI0 MY7mZhOsmRRglCzhQvkK5NCPdoz0zd3acqSJz1pMZ2oqsHCUX87sqEwCSdUoVzvxG/Td 7GErf/5pF71oA/Paoi0qmVFtCdX7P4trDztjYaY9N5fQTgXuFIxck6LDbUicswSJn6eA pfVKtQ5BCJsPZg4fCJKOqNq+BbIzwP/1pzfXFrJSB7WF/6G49vpV34soKoIwZRJNsOXU BGJw== X-Gm-Message-State: AOAM533MYEgzyBgjp0lYh72nSH+lwKyOoyghBD0IUSjhR/XsOgAUvbHN 1cLoIYpeiTyGYp4KlaX92pBcpyJQ+5r0x1yPOvpjE0QQ X-Google-Smtp-Source: ABdhPJx4Vi5wB1nxt6x0sN02HSheK6wPeHexfQU6wFfav/ajSydo0avfupDxxPUIRgfXgoEDxvhtNG8nkv9u+296qJA= X-Received: by 2002:a2e:a288:: with SMTP id k8mr678174lja.367.1624908328853; Mon, 28 Jun 2021 12:25:28 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:7506:0:0:0:0:0 with HTTP; Mon, 28 Jun 2021 12:25:27 -0700 (PDT) In-Reply-To: References: Date: Mon, 28 Jun 2021 21:25:27 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Pipe Operator, take 2 From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) 2021-06-07 21:00 GMT+02:00, Larry Garfield : > 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. > > -- > Larry Garfield > larry@garfieldtech.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php Hi ho, Has it been discussed the difference between the pipe operator and a simple pipe function? Something like function pipe() { $args = func_get_args(); $result = $args[0]; $functions = array_slice($args, 1); foreach ($functions as $function) { $result = $function($result); } return $result; } Usage (ignoring the pesky undefined constant warnings ><): $result = pipe( "Hello world", htmlentities, str_split, fn ($x) => array_map(strtoupper, $x), fn ($x) => array_filter($x, fn ($v) => $v !== 'O') ); There's also pipe operator with object, but that's obviously too verbose compared to the operator (https://github.com/sebastiaanluca/php-pipe-operator). Olle