Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126345 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 80BA01A00BC for ; Fri, 7 Feb 2025 23:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738971211; bh=gFAv8Wq+4lhZpgWDyYqB+eU7ybD2Txah7X0W7neVlA0=; h=Date:From:To:In-Reply-To:References:Subject:From; b=T5Uz81Ih2oyI5oe20YV9HFzlMgx6PsGHRpCj1qktGZZjtKupZ3dLKc9xT9OA2lN9O ZT1RzM6cqPYmppxarjv7VeX2sL+ae4DX9/RZZTERwcSvE7AR1G8d1eLcG1ENdIpZw4 DIWnuR44Z+ExAWEYF7kWamp7G0S3EYHgxLjiz70HO/PeQApGP44hH9pHN7jvs4tuV8 9gjQk8V2BndA9irHilx8PXX4D4cCDnMX2z26jOEtP4xMlpQb55vJh308MPT81q1e8B JhJLaV3Ui4fPDgpNQxK/lAVwEIqSP6j6bSYvu3axbSEqVD3+45LlavbO03Sq2p7+fi ivrJJSuUhmbIg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6F7B318003B for ; Fri, 7 Feb 2025 23:33:30 +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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-b2-smtp.messagingengine.com (fout-b2-smtp.messagingengine.com [202.12.124.145]) (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 ; Fri, 7 Feb 2025 23:33:29 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 61C041140094 for ; Fri, 7 Feb 2025 18:36:14 -0500 (EST) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Fri, 07 Feb 2025 18:36:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=1738971374; x=1739057774; bh=NNjqo+TX+v WpVlKTMq1oCS+0n2O2Ec0J4u0KvGulKzk=; b=BH2yfIaKd2us5+9o5EBf/KhgRG UGQam26kA88vqRBEPM6Mb0wnE+CuxpllZFIzTqfpMTVmwUhQRGx20bRPUH3a0VZM vQ9kuJ2Nw6+2uUj3GoPiR24lNZAbgwKG5Mtz4i8zbTefDlljb8EXEn1NedYdJh2C aS9MfNlNrUs7jWr9SZGZd4z3maCk/0EZoPgrhMmGBjwazJagfyogg4Wj6ExwqUmU m2A/8myl5vEFZamZMsSz1JHXXrFs42QB+s3wmlFG1CXrJtwMXZq4lOZUBi2V7R4y ayuWh9oLqJUcxxY5ndoaEwDcZ8oczNXeH+LL5iFf77f1wDMSeLS4oz6uHLGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm3; t= 1738971374; x=1739057774; bh=NNjqo+TX+vWpVlKTMq1oCS+0n2O2Ec0J4u0 KvGulKzk=; b=T30LEupyinwFxTMS7iaZM6zqFNKVo9tULqeW620v0F6f3LMUKkA +4YvU6sMwm2Ion35+X0YsS60gCS68gvSJfV9SSRGJX6gz0tQp88nM7WTgGHYQg3E wnPv37rHhJlMhzmXWPQJJTvwvlow90AjqofSe1kXxzbyblOP4dJB0nzYSTV6Zr5A ftThtVD2tcnNnFXxC7p+vz1x5fUbeh2bcqTPPQjg4tQR9MtKbPXACeKdN71qN9oH hVVamED3DqFRWHVQu0Pbh53zE7DufnavvVUVYOyTRp5lVVnTU74yx5LrdR6z37Az 26TQ1zvx5OySAluFa33+VrxhxVQ43Mv60hw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeftdeivdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepofggff fhvffkjghfufgtsegrtderreertdejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdf uceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnhepiedthf fhvdffhfettdfgveefgfeugeegudeukeejheeigefghfeiveelfeefueefnecuffhomhgr ihhnpehgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghspdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C6B83780069; Fri, 7 Feb 2025 18:36:13 -0500 (EST) 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 Date: Sat, 08 Feb 2025 00:35:52 +0100 To: internals@lists.php.net Message-ID: <3e01de2d-15b5-48a7-9322-3f92c38957cc@app.fastmail.com> In-Reply-To: References: <5a584219f120385e7e30f6d0a46cc108@bastelstu.be> <040da4e2-2595-42ad-ab94-a0e87aed1a79@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC] Pipe Operator (again) Content-Type: multipart/alternative; boundary=d189cec4ea4e4d71ae4ef52a65243dd5 From: rob@bottled.codes ("Rob Landers") --d189cec4ea4e4d71ae4ef52a65243dd5 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, Feb 8, 2025, at 00:19, Larry Garfield wrote: > On Fri, Feb 7, 2025, at 4:54 PM, Rob Landers wrote: >=20 > > Put another way, what is the order of operations for this new operat= or? > > > > For example, what is the output of > > > > $x ? $y |> strlen(=E2=80=A6) : $z > > > > $x + $y |> sqrt(=E2=80=A6) . EOL > > > > Etc. > > > > I noticed this seems to be missing from the RFC. As a new operator, = I=20 > > think it should be important to specify that.=20 > > > > =E2=80=94 Rob >=20 > Pipe deliberately binds fairly low, so most other operators will happe= n first. Including +, ?? and ? :, for which there are tests: >=20 > https://github.com/php/php-src/pull/17118/files#diff-81789df7e32480162= 6ef4ef8f629cc95dceed4c09073a2b58b70c811bf776904 >=20 > https://github.com/php/php-src/pull/17118/files#diff-56cbcf85bd7f68fa7= a1f837eb15dcc536576986f366976f9642ad20867c471fd >=20 > https://github.com/php/php-src/pull/17118/files#diff-775c14f54cd1a2771= 9d30bfab62024aeb1625bc3f3621fa0e7c16fb1c7957fdd >=20 > So in the examples above, the second would add $x and $y first, then s= quare-root the result. The first, I think would probably need parens to= avoid being invalid but I'd have to try it to be sure. >=20 > --Larry Garfield >=20 It might be good to specify it in the RFC so if there are any strange be= havior, decades from now, there will be an intent to figure out if it is= a feature or a bug.=20 As to the ternary, it is the difference between that example being valid= and this `$x |> $x > 3 ? foo(=E2=80=A6) : bar(...) |> baz(=E2=80=A6)` m= aking sense or not. Personally, I wouldn=E2=80=99t write this code and w= ould use parens to disambiguate, but it=E2=80=99d be handy to know when = doing code reviews of authors who don=E2=80=99t. =E2=80=94 Rob --d189cec4ea4e4d71ae4ef52a65243dd5 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Sat, Feb 8, 2025, at 00:19, Larry Garfield wrote:
<= /div>
On Fri, Feb 7, = 2025, at 4:54 PM, Rob Landers wrote:

> P= ut another way, what is the order of operations for this new operator?
>
> For example, what is the output of<= br>
>
> $x ? $y |> strlen(=E2=80=A6) : = $z
>
> $x + $y |> sqrt(=E2=80=A6) .= EOL
>
> Etc.
>
> I noticed this seems to be missing from the RFC. As a new = operator, I 
> think it should be important to spe= cify that. 
>
> =E2=80=94 Rob
=

Pipe deliberately binds fairly low, so most ot= her operators will happen first.  Including +, ?? and ? :, for whic= h there are tests:




So in the examples above, the second would ad= d $x and $y first, then square-root the result.  The first, I think= would probably need parens to avoid being invalid but I'd have to try i= t to be sure.

--Larry Garfield


It might be good to specify= it in the RFC so if there are any strange behavior, decades from now, t= here will be an intent to figure out if it is a feature or a bug. <= br>

As to the ternary, it is the difference bet= ween that example being valid and this `$x |> $x > 3 ? foo(=E2=80=A6= ) : bar(...) |> baz(=E2=80=A6)` making sense or not. Personally, I wo= uldn=E2=80=99t write this code and would use parens to disambiguate, but= it=E2=80=99d be handy to know when doing code reviews of authors who do= n=E2=80=99t.

=E2=80=94 = Rob
--d189cec4ea4e4d71ae4ef52a65243dd5--