Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126235 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 37CFD1A00BC for ; Wed, 29 Jan 2025 20:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738181626; bh=Uz2A7Df0Yx+n0xnq4Eu8Cw92LaMQdWZaNe1H/nRdtKw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=IIrvA6L93i6jHvikNKitKrjZXbpP3INWHogJ9qH3MPmxquQm20PFNoFlse1Y93/1l rS/ljIEonJH//0yKqnzqYjEE7tmRkshSu70oUpDaiY01rEN0Uc4WkYQS7iKa/Gv9YN OdvCCTbvaxchrQbTAE5omXIq75SQa+reAgtC/l+oq5m/Iw5RbLrRQrkRQVXVu1hEPD euLU0Bth2epikHM9jipj4oZUdkKx9EWyVJTnz90nFy2FT0qCtCz+8fy0dpxVBhhd53 cV/oERqJaM/QjZ9N5wcKs55OLPUtYMRYutxwpPjMRuxOi3WnQr7YOmlxEBUv7daN67 U+iR77iuQXHJw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 25F26180072 for ; Wed, 29 Jan 2025 20:13:46 +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=-0.1 required=5.0 tests=BAYES_50,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 fhigh-b3-smtp.messagingengine.com (fhigh-b3-smtp.messagingengine.com [202.12.124.154]) (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 ; Wed, 29 Jan 2025 20:13:45 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id 646FA25401EB; Wed, 29 Jan 2025 15:16:33 -0500 (EST) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Wed, 29 Jan 2025 15:16:33 -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=1738181793; x=1738268193; bh=GEF7woDxYJ S0Hh53ma7wnX2sMu0awYe8Q4/oQAhmT1g=; b=DoIrWuv89ddemrXFy7xth+oMJS UyigvzdqoMu1BnRvvXBbdNDhxELItflPMuCo2WgJv+LAQrCqnr/Tx0BwXjbNhLt+ 2jXxVMMi3ZSB4WfV6rI5Ub6MmrKytDSuYaGW8/0rYeWAhJc8LXhWboEe7gWqtyQ9 OeEO19qdV5LOr1HxG79NCnvVPFTjZJ/b4nZJcBh6ORXfGdfO2LgOnLdcZQzVYgSV 4jsE/poSJmFIoLXbjh2dRYRfyWzpevT7TBqe/PYDQkJJ4qi3MCqKowDGww3GYLBt wV6vd4rKR7xbNXPO7EqMIkTOeI07lT9tx93jV6ZnkcI9SKpsSY1jKgp1HMdw== 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= 1738181793; x=1738268193; bh=GEF7woDxYJS0Hh53ma7wnX2sMu0awYe8Q4/ oQAhmT1g=; b=lD4v8AyEiDme7FWPdLkTEMEVwoy8ScMyo/WAFddDG9ntr+nLFdH 51CMlwJl7L1Fbjv/xgzkZxE170qclujexIwAkcJDa6Vth6nfExMVrxOcPBXlziU4 I2BMLDm6EhzQnCQuL24MTsEgwW88CH70mw9vD40uxZ9M3DDO5oy0aF9V2Cu1gbyw dV4CUqxqoiSLNEi/9I04QiOdCEBqqBbfUcB82K0Rd3HqAQew0xzfdqX1UFL+IVv3 y2dA2PfhZviYtR4ZKzyZlJheGc+DtUyLoHLmuHCNEAh8YPOqzoXFpqVUbDvAln6m kxLv52u/cG7FPuwbG2oMneDkcuF9sL8Tlow== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefleegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnegoufhushhpvggtthffohhmrghinhculdegledmnecujfgurhep ofggfffhvffkjghfufgtsegrtderreertdejnecuhfhrohhmpedftfhosgcunfgrnhguvg hrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnhep teelgfelheduteetveejhfehleejffekfedugeehiedukefgfedvhfejveeuheefnecuff homhgrihhnpeefvheglhdrohhrghdpthihphgvshgtrhhiphhtqdgvshhlihhnthdrihho necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhosg essghothhtlhgvugdrtghouggvshdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhht phhouhhtpdhrtghpthhtohepthhimhessggrshhtvghlshhtuhdrsggvpdhrtghpthhtoh epihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvthdprhgtphhtthhopehvohhl khgvrhesthhiuggvfigrhihsqdhgmhgshhdrtghomh X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id D7E08780068; Wed, 29 Jan 2025 15:16:32 -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: Wed, 29 Jan 2025 21:16:11 +0100 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , "Volker Dusch" , "php internals" Message-ID: <3b4d9be8-9255-44ab-95c5-ea3045212cf4@app.fastmail.com> In-Reply-To: <3f170549-cfd6-441e-b892-cf51d726dbe8@bastelstu.be> References: <3f170549-cfd6-441e-b892-cf51d726dbe8@bastelstu.be> Subject: Re: [PHP-DEV] RFC: Marking return values as important (#[\NoDiscard]) Content-Type: multipart/alternative; boundary=c666f93a47be4631aa878b752551c3c4 From: rob@bottled.codes ("Rob Landers") --c666f93a47be4631aa878b752551c3c4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Jan 29, 2025, at 20:50, Tim D=C3=BCsterhus wrote: > Hi >=20 > On 1/29/25 20:31, Rob Landers wrote: > > This looks promising! > >=20 > > Why do we need the (void) cast? Wouldn't "@" work and avoid a BC iss= ue? >=20 > The `@` operator also suppresses any other warning or notice within th= e=20 > call chain. That is likely undesirable because it might hide issues on= e=20 > is interested in. See this example (https://3v4l.org/NDtR7): >=20 > function inner() { > var_dump($undefined); > } >=20 > function outer() { > inner(); > } >=20 > outer(); > outer(); > @outer(); >=20 > The `(void)` cast makes the intent of not being interested in the retu= rn=20 > value clear. In C casting to `(void)` is an established pattern of=20 > "using" a value that the compiler would otherwise consider unused.=20 > Likewise will the `void` operator suppress the TypeScript-ESLint warni= ng=20 > of not using returned `Promise`:=20 > https://typescript-eslint.io/rules/no-floating-promises/#ignorevoid >=20 > Best regards > Tim D=C3=BCsterhus >=20 Hi Tim, I understand what you are saying, but I can also just remove the warning= via: $_ =3D outer; Which, to me, is clearer on the intent than (void)outer(); It also happe= ns to make the diffs more natural looking when and if the return value g= ets used during a code review. I'll also note that having (void) doesn't= preclude me from using $_ either. I was mostly just curious as to the reasoning; I don't like it, but it m= akes sense. Best of luck! =E2=80=94 Rob --c666f93a47be4631aa878b752551c3c4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Wed, Jan 29,= 2025, at 20:50, Tim D=C3=BCsterhus wrote:
Hi

On 1/29/= 25 20:31, Rob Landers wrote:
> This looks promising!

> Why do we need the (void) cast= ? Wouldn't "@" work and avoid a BC issue?

T= he `@` operator also suppresses any other warning or notice within the&n= bsp;
call chain. That is likely undesirable because it mig= ht hide issues one 
is interested in. See this exampl= e (https://3v4l.org/NDtR7):

     <?php
=      function inner() {
  &n= bsp;      var_dump($undefined);
&= nbsp;    }

   = ;  function outer() {
     &= nbsp;   inner();
     }
<= /div>

     outer();
     outer();
    = ; @outer();

The `(void)` cast makes the int= ent of not being interested in the return 
value clea= r. In C casting to `(void)` is an established pattern of 
=
"using" a value that the compiler would otherwise consider unused.&= nbsp;
Likewise will the `void` operator suppress the TypeS= cript-ESLint warning 
of not using returned `Promise`= : 

Best regards<= br>
Tim D=C3=BCsterhus


Hi Tim,

I understand what= you are saying, but I can also just remove the warning via:

$_ =3D outer;

Which, to m= e, is clearer on the intent than (void)outer(); It also happens to make = the diffs more natural looking when and if the return value gets used du= ring a code review. I'll also note that having (void) doesn't preclude m= e from using $_ either.

I was mostly just c= urious as to the reasoning; I don't like it, but it makes sense.

Best of luck!

=E2=80=94 Rob
--c666f93a47be4631aa878b752551c3c4--