Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126404 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 F14291A00BC for ; Fri, 14 Feb 2025 11:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1739533410; bh=Xv7cUMxK8KYYfIXHpYF2ivy3KAz1ufZ+szFErrEcxG0=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=Bdy5iMNY1taCwKK1Zg8qiZEg6kgEEOq0CRQJ3Z7y5kZNV3zZaCltHF+5hNgRgNpPs 0DjWXUrtkfyVZfp7DOluNGSGjBTVHmjza8tb+PaA4u6e2HWNbPikW96ppieF/FnPtR 9IwVVpjN60bXcp5ijYZ0PICpuSua1UhqEpI+IAKy4Y8AqJeu5TATE2igweDk8vrCMo YGJtqVbXp1NKEJ6fJ8hFaO2zvC3x6RGSiIxCwhtphkBVZ/4iTwZj8E3VSn2AR6nrzk LFbQVPhnGkd2EuHp6Y94jLyZ7KqT62Cjl03cXCH8MwNdrDx/KZzaGuSzPMWHArAv1g nMu3uXrDdymLw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B7233180050 for ; Fri, 14 Feb 2025 11:43:29 +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=3.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) (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, 14 Feb 2025 11:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1739533570; bh=Xv7cUMxK8KYYfIXHpYF2ivy3KAz1ufZ+szFErrEcxG0=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=Yg/jDmqSj0h59kP6gJ3efr0qnUmtO7cDNoifCosGDggbyB9llCA5Qqv77Lhh8ncO/ zAy5Uw8ajZur8bq+FxGHeHHZ/dBg6+fpZe8Ob13P5X3sjZUON3hn5wxOeO0f+AVnrV 6rsgvijUXF94qlb0vDKxzVkoT5otkaSi4HR+qZ+BFeukWpMAGP5XtqmcDDi5ORi+q5 4YH+GKnjoIOFhRWpZRZ/ppFlwrE/cNjel2k/ybhcfFK0UmH2EKzxSFsLkn5iJQ9hbF A8Px5nNHVtZpEPuKuTFQi/LLTv3NOzuRdgMV0rAyh1NjOVi3PFOxRNUoPmN5D6Le7L hUUmcJ8epCTGQ== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id A4E1810C087; Fri, 14 Feb 2025 11:46:10 +0000 (GMT) Date: Fri, 14 Feb 2025 11:46:10 +0000 (GMT) To: Volker Dusch cc: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , php internals Subject: Re: [PHP-DEV] Re: RFC: Marking return values as important (#[\NoDiscard]) In-Reply-To: Message-ID: <83f33b28-b630-0afe-2c7d-2f899cd722ca@php.net> References: Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1003179381-1739533570=:13815" From: derick@php.net (Derick Rethans) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1003179381-1739533570=:13815 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Wed, 12 Feb 2025, Volker Dusch wrote: > On Wed, Jan 29, 2025 at 4:12=E2=80=AFPM Tim D=C3=BCsterhus wrote: >=20 > > Volker and I would like to start discussion on our RFC to allow "Markin= g > > return values as important (#[\NoDiscard])". > > > > Please find the following resources for your reference: > > > > - RFC: https://wiki.php.net/rfc/marking_return_value_as_important > > - Implementation: https://github.com/php/php-src/pull/17599 > Hello everyone, >=20 > it's been two weeks, but given the feedback we received, we don't feel=20 > the discussion didn't reach a conclusive resolution yet. >=20 > So we wanted to solicit additional opinions. In an attempt to=20 > summarize the discussion, how we see it, there are two main points of=20 > contention we'd like to discuss further. >=20 > a) Intentionally discarding the return value >=20 > The `(void)flock($fp);` syntax was the main thing discussed on the list. > With `$_ =3D flock($fp);` as the most suggested alternative. >=20 > The issue with using `$_` as it currently stands, is that the unused=20 > variable would be cleaned up by OPcache. Should we instead have a=20 > special case in OPcache ensuring it does not apply its optimization to=20 > a variable if it's named `$_` instead? The semantic difference would=20 > be that $_ would keep returned values (and objects) alive and in=20 > memory, whereas (void) would discard them immediately. Leading to=20 > different times when, for example, destructors would be called. > > The consequence of this would be that 3rd party tools like IDEs and=20 > Static and Dynamic Code Analyzers would also have to build that=20 > special case in to not produce "unused variable" warnings. >=20 > We're also happy to change the secondary vote to "(void) vs $_" as we=20 > feel there needs to be a way to discard the return value consistently=20 > for this to be a complete and usable feature. I would not be in favour of special casing this, and henceforth the=20 (void) cast makes more sense to me. Mostly, because the special casing=20 has to be done in many places, and in many tools. =20 > b) Naming of the attribute >=20 > Nobody mentioned this on the list, but before opening a vote we'd like=20 > to heard if the attribute name makes sense to you. >=20 > We've chosen #[NoDiscard] as it's also used in C and C++. See [1] for=20 > the full list of references. If you feel this doesn't fit with PHP, we=20 > welcome other suggestions. I think it fits, and there is already precedence. cheers, Derick --=20 https://derickrethans.nl | https://xdebug.org | https://dram.io Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/suppo= rt mastodon: @derickr@phpc.social @xdebug@phpc.social --8323329-1003179381-1739533570=:13815--