Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127547 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 68B6D1A00BC for ; Tue, 3 Jun 2025 02:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748917420; bh=RwuKuKy7opG1AH8I9MGTxzBA95kCk2P2t3b97X263QQ=; h=Date:From:To:In-Reply-To:References:Subject:From; b=mYiuVKXvAv/Jl7lpvEckS174mhgMQeSvIppAwYPDa4Nv8xsAM2fm5evlLsF2kD9Y1 tdbnw5Xf9uQkkGnVN0k7WjkjaFiU8RsqQioDlZyx1CDEzaO0laILLoLX757tXcgYhs taIgct4HrIyQ6LGiP5IQAP4A7p/xwHpf09a3IOPIMaR4Hm+wJjvrnWAJ/yU5+yMTds dhyq8XGSqLsg8xWb/JiGbVEy6Dp/axukamiL6c06Tg2gtX5yVDwY6tR311FJbMxmBe rK8S2/OXBuQFTV3weFWKytCVcNyPMM72NRiAFrLHxC58dhtweaFvdJz2QRcz+icPcC Iu84PrVX2nIEw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 23BB7180041 for ; Tue, 3 Jun 2025 02:23:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 3 Jun 2025 02:23:39 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 93FC913802AB for ; Mon, 2 Jun 2025 22:25:43 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Mon, 02 Jun 2025 22:25:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm1; t=1748917543; x=1749003943; bh=tL54a/aLvA+1Jmk9bP/Lb kNd3y+qLzCi3UNzWZyibl4=; b=lj9ox9hkiJgz2bb/nnHPrnKrZOPR+RA72oz0C XOsNTQ7JjnXUlLwce+6Bgfnf8vrUaA8h0hY++7Hrtq5lV1kFb3Vs1XhVUxg5Y+q4 aP/gYJQFw/NUy5wJjUrxgPkYVfESBZuatPpDeZecE9SkDdvfpa2lRTm98+Kpw1WT e9kMdRbz9tG3jJfuzJdiEZcWmaMjbckewaVP2bMtAE9jQWhGYhqIlvLIcLLxvkaz MG6uufeZ8+wmjura7fv/nAZ8szwUJzeT7HKb+qqMMvs37+o5PbZaQvES6XUyK7P6 4TQZjmTKqG9A8Ln5rVSNMAyVLntAKq8xOZGKigaKQjJP4pvVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1748917543; x=1749003943; bh=t L54a/aLvA+1Jmk9bP/LbkNd3y+qLzCi3UNzWZyibl4=; b=OzGZKPfk9cI41C2br DwigRvH9lqZpoFu5O7Of/HgIxM5fC/CSNJA1MzJwcl8xCNIrAKm/yVTJp0OY+52I I/5YqrDTqJDPdXdkZ9kmlUeTSU6pbiTxJ16lkIqYX8bh1fJ8/awLPuFJehRG8Ol0 Ct/K0C7cu52z+lZ3oD6Ud8WrVJVdUMDb3LBVRpMAMwmL6CBRuLv/JlwOX0zv+fKb 06wWyewutXHbIe9w0IaiI7o3CvGwFQLq79D+cxTRpX+GO0QxhDgpJx7dppMPMvkh d/y/zfpYxXfOOWPuSsu7qPa3u41iWf/YLO0O83zEm0dAEsVLv05filIFj8lZuXko 9Ok4A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgdefleefgeculddtuddrgeefvddrtd dtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggft fghnshhusghstghrihgsvgdpuffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftd dtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenogfuuhhsphgvtghtffhomhgr ihhnucdlgeelmdenucfjughrpefoggffhffvkfgjfhfutgfgsehtqhertdertdejnecuhf hrohhmpedfnfgrrhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghl ughtvggthhdrtghomheqnecuggftrfgrthhtvghrnhepvdeljeekiefhueevheeghffhue ektdektdefvedufeffuddvleejjeejiefhhfejnecuffhomhgrihhnpeefvheglhdrohhr ghdpghhithhhuhgsrdgtohhmpdhphhhprdhnvghtnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghh rdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtth hopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 2B26D700061; Mon, 2 Jun 2025 22:25:43 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: Tb59d627fb5f6e7a2 Date: Mon, 02 Jun 2025 21:25:18 -0500 To: "php internals" Message-ID: In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Pipe Operator (again) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Mon, Jun 2, 2025, at 3:41 PM, Dmitry Derepko wrote: > Hi Larry! > > > > It's been a long, long way to get this feature, awesome work. > > > > Have you considered adding a compose function that does the same thing=20 > but in the classic PHP function style? > > > > There's not much difference between the new style: > > > > > > $processor =3D fn ($data) =3D> htmlentities($data) > > |> str_split(...), > > |> fn($x) =3D> array_map(strtoupper(...), $x), > > |> fn($x) =3D> array_filter($x, fn($v) =3D> $v !=3D 'O=E2=80=99= ); > > > > and the old one: > > > > $processor =3D compose( > > htmlentities(...), > > str_split(...), > > fn ($x) =3D> array_map(strtoupper(...), $x), > > fn ($x) =3D> array_filter($x, fn ($v) =3D> $v !=3D 'O'), > > ); > > > > But the classic looks better when you create real pipes.=20 > > > > I=E2=80=99ve created examples with comparison. > > > > https://3v4l.org/jY0Vg > > https://3v4l.org/87Sj2 > > https://3v4l.org/4EE6b > > > > > > New syntax just makes code shorter, but the compose function still hav= e=20 > benefits: > > - it will be able to add a polyfill for older versions > > - it will be possible to write the first function without passing the=20 > first argument ($data in the "fn ($data) =3D> htmlentities($data)=E2=80= =9D) > > - it will be possible to re-use the compose function along with the ne= w=20 > operator $data |> compose(=E2=80=A6$functions) Pipe and compose are importantly different operations. I've had user-sp= ace implementations of both available for years in crell/fp: https://gi= thub.com/Crell/fp/blob/master/src/composition.php I'd love to have a compose operator natively in PHP, too. The RFC for t= hat is already written, just needs code. I hope to formally propose it = soon: https://wiki.php.net/rfc/function-composition --Larry Garfield