Re: Re: [RFC] Context Managers, v2

From: Date: Tue, 24 Nov 2026 22:54:38 +0000
Subject: Re: Re: [RFC] Context Managers, v2
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-133218@lists.php.net to get a copy of this message
On Sat, Nov 21, 2026, at 9:59 PM, Larry Garfield wrote: >> the returned value from file_for_write isn't used and >> should trigger a >> warning. > > That seems reasonable; I'll have to confirm with Arnaud that we can > implement that. > >> 6. Is there a way for the generator to specify that the *yielded value* should >> not be discarded? The current RFC text says >> >>> If no VAR is specified, the yielded value is ignored. >> >> and while NoDiscard would highlight the ignoring for a >> function return, it >> doesn't for generator yields. Update here: this is actually not feasible for either the return or yield, because right now, generators don't do that. A #[NoDiscard] on a generator function means "don't discard the generator object," and says nothing about the return or yield. Changing that means changing the behavior of NoDiscard, which is out of scope, and would also impact performance. I've added a note to Rejected Features on this front. --Larry Garfield

« previous php.internals (#133218) next »