Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126569 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 DD4171A00BC for ; Tue, 4 Mar 2025 22:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741127659; bh=aEquhUfuw3Mo+7EWhnVhG+oU2s2przjZGlOCn3p5g7A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JI9pODDzLVJ8c1p+BMNtcTHoxukYVQsy2eNuc5DoqpbCm47r07QFuldnd34BQJdHM kLUJ4FHdKtAEJYqSXoqQ2nr6SeB8guJrvdytYHES3tRiblFgivRGMIDInUya9Vldlh S6yfD6QO08R/3kdr9IX5a7ybj8rGPeJejmBgqSF6UJoGVCumwKtFX7RQ4kdLrnpB39 lKzE+67saP6PFW5zbPX1CKgGp/Vj9pqjwkLIxauPYpCdBMpiGfASdq8cRwxldFpwW0 J/qj6Aj9EFSVqHrYUnDhbq7DYDR/DfG7P11HqSZebXowuh/EeO8HiJrosEMHdKKmBJ ALO72FluzRiyw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BF1BA180082 for ; Tue, 4 Mar 2025 22:34:16 +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.0 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (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, 4 Mar 2025 22:34:15 +0000 (UTC) Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-6fd80f30ba5so21349827b3.3 for ; Tue, 04 Mar 2025 14:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741127811; x=1741732611; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aEquhUfuw3Mo+7EWhnVhG+oU2s2przjZGlOCn3p5g7A=; b=hXS0VYHmO4GLm+NO5mGHqrRQvdlPZjs61gpMOq1wcmtsGwJgZljwDW/TCyhrP6M1ds aETRIWoUojE/5x8CwZsXU9uFHely35IEVn2reXfvrkEM9zda58Mwr3T3GhKjbZsI4OLv hjp8EuKUnJcaiGJFoWfo3rln0/SJv4QbrtBNKpVD2vw2sWhiAdc41MCtPSw+tV6R2ygk V1RAarKUC/8PbpzPfMS57lGRnKgB7YuUmi9g8jgt2BTPiYdGz5J/bGxNgxoUVMHykIJz R3hf6eP+Jy6KOAwc+9VBunn3zkXfO9Wk9iksC6bXVvQYBaXE+EwIacAavZGtQvMDo8AW o2EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741127811; x=1741732611; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aEquhUfuw3Mo+7EWhnVhG+oU2s2przjZGlOCn3p5g7A=; b=sExqHMRaEyckf4GFMNEhR8OV5f9be1xi6gYPYSwKIfnpdhQPYvEGM3BJLGPNXG6l8w W0FkZ89PeylqvS7MrX1APAZMZFoWmmj53xnH+DCvqumgM2hDDmN/yaeypEv3jqNoVv3r cyxu9XNUZwRaCg1DhrVcK7aC44YY1t+xsm0iLB4A4Do3ymH/8i4zlvlWLLlAOqFYE725 OS9va5cDRp2cXq+UVLSka6OZCBLwS8BltcHw188hRq6yWC4IT3Iqutrke3GwItVo/FrR lKNbolnS7lixc6WUA3KcOTFXpe7ArGe3B2V4DsXERzTFeCqkjjj6aB7Jb/qhGJQITM7r 0jRg== X-Forwarded-Encrypted: i=1; AJvYcCXxufR3ycQD+6gunU2Og4aCi4dYYJgp4w0REWQJXRjkYcolL4gTx4j6JDqKboSko5oYEcfmfKLlmY4=@lists.php.net X-Gm-Message-State: AOJu0Yw7t5QuYHUQ5THrlxpEVaCzKR7hCpdQvI2rzb9EQJwFMrPSy2RI MvccUGc3aLUwskWnypLG6YfS2f8u0HGc/3Qo5+YenGW9KC7OLHaBcI26bjv1w+SmBCyedcq4EFm GuRRilyITR+EFf/6+qXpu1lcWpLA= X-Gm-Gg: ASbGnctuSwuEG4vb7pURE3bTWQBuJZ+qSPppEzOjt5hV9EaRfJGNWFIaNtPXMvbwBKV SAVUFdNZO9TFHEQ5KotxOhGo6YkwM/Gc1LQFtoFsCWp4s0T871LU5RxHa6i4BYutolwpd7cbDxZ TkLuSg9jDeT3To12UlrLX9T0RrPg== X-Google-Smtp-Source: AGHT+IGRSWpcaiQ/+QwsH+QaUNmcvIbL/fvNyuh1vD3FsAEmboingnNQWRyN/kfh0tYEE6WrD+JI65yYIickTmJtP00= X-Received: by 2002:a05:690c:6b83:b0:6fd:2f47:f4e6 with SMTP id 00721157ae682-6fda2f46e85mr16738257b3.12.1741127810657; Tue, 04 Mar 2025 14:36:50 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <55b798d4-dcd7-4d81-852b-b78294cdc39d@email.android.com> <1a980468-c5f3-485b-9e8b-8c97d6ac4802@bastelstu.be> In-Reply-To: Date: Tue, 4 Mar 2025 23:36:35 +0100 X-Gm-Features: AQ5f1Jqlqii7BUWE3dD1lbVIBzznoFYd8lG0r_7iXJXrp-cEVgkYg1qdaJNWgFg Message-ID: Subject: Re: [PHP-DEV] Re: RFC: Marking return values as important (#[\NoDiscard]) To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: "Marc B." , Volker Dusch , php internals Content-Type: multipart/alternative; boundary="000000000000a9b950062f8be8bf" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000a9b950062f8be8bf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 4, 2025, 23:22 Tim D=C3=BCsterhus wrote: > > > Or identify that the function has the NoDiscard attribute and based on > that > > do not optimize away the variable? > > First things first: It's not a super important optimization to have, the > assignment to a variable is one of the cheaper operations - and given > that OPcache needs to know about the function it's also pretty limited > in application. Of course you can also always just remove the assignment > yourself (or ask your favorite IDE or static analyzer to point it out > for you). > > That said: Checking for the attribute and performing the optimization is > likely possible, though likely of limited cost/benefit. In any case that > would be an implementation detail that does not change observable > behavior. The RFC defines that `(void)` or alternatively `$_` will be > the solution that guarantees that the warning will be suppressed (which > will then also be part of the documentation), how exactly that will work > internally is something that can and will change when refactoring and > evolving the engine and OPcache. > > Thank you for explaining. My motivation for asking is because I believe that special casing $_ variable might not be a desirable solution, and I personally find it worse than (void) casting. And so, people might vote "No" for the first vote because they are not happy with either results of the second option. And maybe we can find a technical solution that doesn't require a behavior/documentation change if second vote fails. I agree that this optimization is not really important, so finding a way to avoid it would be nice. -- Alex --000000000000a9b950062f8be8bf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Mar 4, 2025, 23:22 Tim D= =C3=BCsterhus <tim@bastelstu.be&= gt; wrote:

> Or identify that the function has the NoDiscard attribute and based on= that
> do not optimize away the variable?

First things first: It's not a super important optimization to have, th= e
assignment to a variable is one of the cheaper operations - and given
that OPcache needs to know about the function it's also pretty limited =
in application. Of course you can also always just remove the assignment yourself (or ask your favorite IDE or static analyzer to point it out
for you).

That said: Checking for the attribute and performing the optimization is likely possible, though likely of limited cost/benefit. In any case that would be an implementation detail that does not change observable
behavior. The RFC defines that `(void)` or alternatively `$_` will be
the solution that guarantees that the warning will be suppressed (which will then also be part of the documentation), how exactly that will work internally is something that can and will change when refactoring and
evolving the engine and OPcache.

Thank you for explaining.

My motivation for asking is because I believe that special casi= ng $_ variable might not be a desirable solution, and I personally find it = worse than (void) casting.
And so, people might vote= "No" for the first vote because they are not happy with either r= esults of the second option. And maybe we can find a technical solution tha= t doesn't require a behavior/documentation change if second vote fails.=

I agree that this optim= ization is not really important, so finding a way to avoid it would be nice= .

--
Alex



--000000000000a9b950062f8be8bf--