Re: [RFC] Context Managers, v2

From: Date: Thu, 05 Nov 2026 18:18:19 +0000
Subject: Re: [RFC] Context Managers, v2
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-133006@lists.php.net to get a copy of this message
> On 6 Nov 2026, at 00:46, Larry Garfield <larry@garfieldtech.com> wrote: > > Hi folks. Based on the feedback and problems with the previous Context Managers RFC, Arnaud > and I have a new approach to present: > > https://wiki.php.net/rfc/context-managers-v2 > > It basically swaps the two-method approach in favor of "it's a generator, you're > welcome." The result is, I think, both simpler and more flexible, and resolves a number of > other issues as well. More details in the RFC. > > There is a linked implementation, though Arnaud warns it's only partially complete so go > easy on it. :-) But the design in the RFC is all ready for review. > > -- > Larry Garfield > larry@garfieldtech.com > Hi Larry, TLDR: why => rather than as? As a userland developer I like what this is trying to achieve. I'm not knowledgeable enough about the internals to comment on the finer details or their ramifications - I just have a bike shedding suggestion/question which seemed glaring to me so I wonder if it's because of an ambiguous syntax or some other issue? The => symbol seems odd to me, given how it's used elsewhere (generally as an indicator of a key/value pair, whether in an array or match block) and how generators/iterables are used elsewhere (ie foreach as) Your example is: using (file_for_write('file.txt') => $fp) { Whereas to my eye this seems like a much more obvious choice: using (file_for_write('file.txt') as $fp) { Anyway, just a thought. Cheers Stephen

« previous php.internals (#133006) next »