Re: [RFC] Context Managers

From: Date: Wed, 06 May 2026 13:31:01 +0000
Subject: Re: [RFC] Context Managers
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-130784@lists.php.net to get a copy of this message
Le 22 avril 2026 20:28:15 GMT+02:00, Larry Garfield <larry@garfieldtech.com> a écrit : >I will stop here, however, and ask for input from the audience. (Not just the regulars in this >thread of late, but all of you reading this.) Including if you have an alternate approach to the >three listed above that would have notably fewer cons. > >--Larry Garfield I prefer the void return and throw if needed approach, it looks way more understandable. I was confused by that part when reading the RFC and really surprised that returning an Throwable on success is ignored, which is not clear at all when reading the interface. The in-out parameter works too but is a bit weirder, and makes it unclear what happens if exitContext throws. It's also unclear to me in the current desugarized version what happens when exitContext throws, the reset of the context var does not happen ? There is nothing to handle that. Côme

« previous php.internals (#130784) next »