> On Dec 15, 2025, at 18:21, Deleu <[email protected]> wrote: > > On Mon, 15 Dec 2025 at 20:01 Ben Ramsey <[email protected]> wrote: >>> >>> >>> Since the only feedback on what to use for "as" was that => makes sense, we >>> have changed the RFC to use => instead. So the new syntax is >>> >>> using (new CM() => $cVar) { >>> // Do stuff here. >>> } >>> >>> Going to be controversial here, but this is confusing, because it operates >>> in the exact opposite of every other usage of => we have. With associative >>> arrays, the left is assigned to the expression on the right; with arrow >>> functions, the return value is the expression on the right; with match, the >>> expression on the right is returned. >>> >>> This is going to be easy to get wrong. >> >> >> I agree with Matthew. >> >> I think it makes more sense to reverse them, like this: >> >> using ($cVar => new CM()) { >> // Do stuff here. >> } >> >> I think it’s still clear what this is doing, when reading it. >> >> Cheers, >> Ben > > I also agree with Matthew but the reversed proposed here looks very very > awkward to me. I think the most natural thing is the “as” but I may have > missed the discussion on why it had to be changed. > > Thinking of foreach ($array as $value), an item from the array (left) is > assigned to $value (right). That seems symmetrical to using (new Manager as > $manager) where the instance (left) is assigned to the variable (right). Also > when using aliases on the top of the file “use Foo as Bar;” as is also > assigning the left to the right.
This argument makes sense to me (i.e., using `as` instead of `=>`). I’ll go back through the thread to find the arguments against using `as`, to understand why it changed to `=>`. Cheers, Ben
