Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126973 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 qa.php.net (Postfix) with ESMTPS id 3E9811A00BC for ; Sat, 29 Mar 2025 14:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743259431; bh=6N+4qMFnlRYalT/VD9GrD19fpgFLs3Yl1t3k7mrurkc=; h=Date:From:To:Subject:In-Reply-To:References:From; b=C9qiBcZ20wvSnSdFdJV9bZUBM4HI8B4TAZx8h31OdcwzC/U7LX3jKT0U1IDgeLkd+ AMXDbiBMjNYrq8WUZ493wMV3jObF80zIAavpK6MEDXC0DV/I0Nd2dGq8utHejmhxaV xl7A8C0F1MFQTd1YIN2MIhNaYWIDFXL6yP0JU4Ma8akwlZK7+ZsxoelWEia4GN0aX4 TrNFMOJGo15pO7TJCy62QaDsA/M0zv1WZw5xnn6/zSN4WVRepSNCCoU5ENw28NrYTO 7AMUzgUKgO90zOc8Yz0x6EmQIXXVjk07XBVak+LuZnndCgaBCnzUYukPRYXFW+klge 2uF8oVkjMZkVw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AC5E918006A for ; Sat, 29 Mar 2025 14:43:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from letterbox.kde.org (letterbox.kde.org [46.43.1.242]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 29 Mar 2025 14:43:49 +0000 (UTC) Received: from [IPv6:::1] (p200300e49f227859d57954f7314ec18d.dip0.t-ipconnect.de [IPv6:2003:e4:9f22:7859:d579:54f7:314e:c18d]) (Authenticated sender: ojschmidt) by letterbox.kde.org (Postfix) with ESMTPSA id 233F7327B18 for ; Sat, 29 Mar 2025 14:46:16 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kde.org; s=users; t=1743259576; bh=axlqeB5+PIV0+ny+qRsiXi/ZhWcUbu4LoMhriI8isS4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=IdLCmTdN2ai05LEkUOoUXBg6MqXrc+5czsa6M9hhBv0b+TpRNaU4+4jFzChL4BF06 9Ni8E9FSHxcN2F61TYdd4Mvk7LsmHqESyKE4Ghg4ptYqZ8ZxYzwmhzUoSqc+ObmegI fadJPScdgfGDhdswa4yr9r7P1hKYZuZdisRJyShDexK54FU8h4r3LDL5tQKQi7QgGU 3j7qVYI7EWnvPFqaV3dwOtZ4GJciTGHvlZmzGBkLkjZYUqbO3xZ+YcCPfnmlWqVAGa k4pDbrMqifsEMUljNYQ6EXk7zpzLDsWM3D1DLW8YrYXSp3TUkKUfR3emWtTUWJW0xm s+ZG8f+DFyS5Q== Date: Sat, 29 Mar 2025 15:46:16 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Pipe Operator (again) In-Reply-To: References: Message-ID: Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=----4OU6WXF5FRE56VNDQINCMLJ0WO6HBU Content-Transfer-Encoding: 7bit From: ojschmidt@kde.org (=?ISO-8859-1?Q?Olaf_Schmidt-Wischh=F6fer?=) ------4OU6WXF5FRE56VNDQINCMLJ0WO6HBU Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ilija and Larry, thank you so much for your great work bringing PHP forward=2E I have been = passively reading this list for a while and would like to chime in with two= thoughts=2E > Pipes would no longer have the form of expr |> expr, where the right-han= d-side is expected to return a callable=2E Instead, it would have the form = of expr |> function_call, where the left-hand-side is implicitly inserted a= s the first parameter of the call=2E > >namespace Iter { > function map(iterable $iterable, \Closure $callback): \Iterator; > function filter(iterable $iterable, \Closure $callback): \Iterator; >} > >namespace { > use function Iter\{map, filter}; > > $result =3D "Hello World" > |> str_split() > |> map(strtoupper(=2E=2E=2E)) > |> filter(fn($v) =3D> $v !=3D 'O'); >} With named parameters, you could even make this approach work without the = suggested (but still useful) new Iterator API: $result =3D "Hello World" |> str_split() |> array_map(callback: strtoupper(=2E=2E=2E)) |> array_filter(callback: fn($v) =3D> $v !=3D 'O'); or $result =3D "Hello World" |> str_split() |> array_map(callback: strtoupper(=2E=2E=2E)) |> array_filter(fn($v) =3D> $v !=3D 'O'); I am also wondering whether |> and -> should have the same operator preced= ence=2E Best regards, Olaf Schmidt-Wischh=C3=B6fer ------4OU6WXF5FRE56VNDQINCMLJ0WO6HBU Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi Ilija and Larry,

tha= nk you so much for your great work bringing PHP forward=2E I have been pass= ively reading this list for a while and would like to chime in with two tho= ughts=2E

> Pipes would no longer have the form of expr |> expr= , where the right-hand-side is expected to return a callable=2E Instead, it= would have the form of expr |> function_call, where the left-hand-side = is implicitly inserted as the first parameter of the call=2E
>
>= ;namespace Iter {
>=C2=A0=C2=A0=C2=A0 function map(iterable $iterable= , \Closure $callback): \Iterator;
>=C2=A0=C2=A0=C2=A0 function filter= (iterable $iterable, \Closure $callback): \Iterator;
>}
>
&g= t;namespace {
>=C2=A0=C2=A0=C2=A0 use function Iter\{map, filter};>
>=C2=A0=C2=A0=C2=A0 $result =3D "Hello World"
>=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |> str_split()
>=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 |> map(strtoupper(=2E=2E=2E))
>=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |> filter(fn($v) =3D> $v !=3D 'O= ');
>}

With named parameters, you could even make this approac= h work without the suggested (but still useful) new Iterator API:

$r= esult =3D "Hello World"
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |> str_s= plit()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |> array_map(callback: st= rtoupper(=2E=2E=2E))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |> array_fi= lter(callback: fn($v) =3D> $v !=3D 'O');

or

$result =3D "H= ello World"
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |> str_split()
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |> array_map(callback: strtoupper(= =2E=2E=2E))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |> array_filter(fn($= v) =3D> $v !=3D 'O');

I am also wondering whether |> and ->= should have the same operator precedence=2E

Best regards,

Ol= af Schmidt-Wischh=C3=B6fer
------4OU6WXF5FRE56VNDQINCMLJ0WO6HBU--