Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126236 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 14B071A00BC for ; Wed, 29 Jan 2025 22:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738190719; bh=31YQPFPf3yS81R2f6vTEepfBFsHb2ThNPkNR7NRWimQ=; h=From:Subject:Date:References:To:In-Reply-To:From; b=n0pLgsQbZt4T1vEHWTnGLNfYLMNhPhc76XcYpZbKylyzLUuPG2HUQHXQ1/KSellYq XX4Ys1BV72clt66JEbOxT/OmhvTxBhIbEndXvGEBORN2zTu8dqP3YHmoZKdTDadu/B njdTa6lHwXqmn+rTsl7OilaHQIxbBOxTTX4QuHbkC1hXqpZ00WXg998d5y71cViEx/ f54wGTDTcnc1fx1S8kcUvY32XQl8J3RDJA+GTF5iGPcl/O8b2QiKLslSoKTZIn9Fln fMlhTpdIEkyh8uzCm8B3JaNL3rcEFa+JQriKmssZ5N8+Zt+EaZ0zmqToJw70ekj4am cZmjC4CuxW4ug== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 45F10180072 for ; Wed, 29 Jan 2025 22:45:18 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail.gna.ch (mail.gna.ch [212.45.196.109]) (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 22:45:17 +0000 (UTC) Received: from smtpclient.apple (unknown [IPv6:2a02:1210:2e0f:4100:7080:7e3c:157b:8e07]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id A93133A1310 for ; Wed, 29 Jan 2025 23:48:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cschneid.com; s=default; t=1738190883; bh=31YQPFPf3yS81R2f6vTEepfBFsHb2ThNPkNR7NRWimQ=; h=From:Subject:Date:References:To:In-Reply-To; b=kyOQZzZLamLxnDgNB0UiiDP48Kp2xAA4JH2Qarewgp+I98VLLQARAAq45uk0wOzdw FXW30aah0vfo3W+WM5++UikU5+V6dHSeRjnWEw6QaEupmUpA8yYi2lbpcD0/O/h7Pj rHPfWNO+skIxj64GvTX59UwZEmbzPN4vElg6HYN0= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.400.131.1.6\)) Subject: Re: [PHP-DEV] RFC: Marking return values as important (#[\NoDiscard]) Date: Wed, 29 Jan 2025 23:48:03 +0100 References: <3f170549-cfd6-441e-b892-cf51d726dbe8@bastelstu.be> <3b4d9be8-9255-44ab-95c5-ea3045212cf4@app.fastmail.com> To: php internals In-Reply-To: <3b4d9be8-9255-44ab-95c5-ea3045212cf4@app.fastmail.com> Message-ID: X-Mailer: Apple Mail (2.3826.400.131.1.6) From: cschneid@cschneid.com (Christian Schneider) Am 29.01.2025 um 21:16 schrieb Rob Landers : > On Wed, Jan 29, 2025, at 20:50, Tim D=C3=BCsterhus wrote: >> The `(void)` cast makes the intent of not being interested in the = return=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 >=20 > I understand what you are saying, but I can also just remove the = warning via: >=20 > $_ =3D outer(); >=20 > Which, to me, 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 during a code review. I'll also note that having (void) = doesn't preclude me from using $_ either. I think the (void) cast is familiar for people from C or the like, the = only caveat is that it is not backward compatible, i.e. code using it = won't work on older versions of PHP so migrating to it is not seamless, = so it probably should not be used for a while in public libraries / = packages. I guess another option would be to define a function nop($_) {} and then use nop(outer()); but my question is whether $_ =3D outer() and nop(outer()) will be = guaranteed to not being optimized in a way which causes the warning to = reappear. I don't know much about the optimizations being done but this = could be an issue in the future, no? Regards, - Chris