Hi

Am 2025-12-16 09:08, schrieb Rowan Tommins [IMSoP]:
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).


This is the way to read the "as" syntax, yes; as I've said in a few places, a Context Manager is like an iterator that goes around once.

That definition doesn't make sense to me. An iterator that only ever emits a single value is not actually iterating anything and it would never occur me to interpret it like that. As I had also noted in my reply https://news-web.php.net/php.internals/129582, it is absolutely magic to me that `break;` would target `using()`.

My favourite among my own suggestions was "using($cValue from new CM())", but Larry didn't like the reversed order. I also suggested 'using(new CM() for $cValue)", but I don't think that's as clear.

FWIW: Using `from` would be somewhat consistent with `yield from`. Using `for` would effectively invent another meaning for an existing keyword, something that folks disliked for `use()` as the initial block scoping keyword.

Best regards
Tim Düsterhus

Reply via email to