Re: [RFC] Context Managers
| From: | Tim Düsterhus | Date: | Sun, 18 Jan 2026 10:52:56 +0000 |
| Subject: | Re: [RFC] Context Managers | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129771@lists.php.net to get a copy of this message | ||
Hi
On 1/15/26 17:01, Larry Garfield wrote:
The core point here is that we needed some way to successfully terminate the block earlyAs I asked in my previous email: Why? You state this requirement as if it was an undisputable fact, but I don't see how it is *needed* and no reasoning is given.
What do you mean by “disallowcontinueis really just to mirror what switch does with it. If the consensus is to simply disallowcontinueentirely (which is inconsistent with what switch does today), we're OK with that. I don't feel strongly either way, so we're looking for a consensus.
continue entirely”? Does this include continue 2; targeting a loop or is this just referring to “continue targeting using()?
If there's a different keyword than break you think would make more sense here, please do suggest it and provide an argument. But "break does the same thing here it does in switch, foreach, and while" seems like a pretty straightforward approach.
“break does a different thing here than it does in if, else, try, catch, finally, namespace, and declare” doesn't seem like a straightforward approach to me.
To me using() feels much closer to an if() (or try, given the desugaring) than to a loop. As I had mentioned in my email https://news-web.php.net/php.internals/129582, goto *is fine*. And do-while(false) would also work as a restricted form of “forward goto”.
Yes, I meant the first code block in the “Implementation” section. To me that felt like the “top” of the RFC. I didn't mean to suggest to move it elsewhere, I requested an example of what:With regard to the desugaring listed at the top: Can you please also provide the desugaring for the case where no context variable is specified for completeness?Desugaring at the top? The desugaring is explained about a third of the way down. :-) Is that what you mean? (In the "Implementation" section.) It doesn't make any sense to go into that level of detail in the introduction.
using (new Manager())without the
=> $var results in.
Best regards
Tim Düsterhus