On Thu, Nov 5, 2026, at 12:18 PM, Stephen Reay wrote:

>
> 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. 

The v1 RFC originally used `as`, which is what Python uses as well.  However, a 
lot of people were concerned that it implied that the left side expression 
would be "used as" the right side variable.  While in some cases it might be, 
the typical case is that it's not.  The context variable is emitted by the 
context manager, but is not the same thing.

At the time, no one could really agree on a better keyword.  But => was right 
there waiting to be used, and already has an "evaluates to" or "yields" or 
"produces" meaning, which is roughly accurate to what happens here.

I don't mind `as`, personally, but the consensus before seemed to not care for 
it.

--Larry Garfield

Reply via email to