On 14/03/2023 22:54, Larry Garfield wrote:
However, I agree with Ilija that the original proposal to just do it automatically would be better; and if that didn't pass, I have no expectation that an alternate with a funky new syntax would do any better.
Well, a large part of my resistance to automatic capture is that it makes variable scope less visible at a glance. This avoids that by still having a marker for "I am from another scope", but a much less verbose one than the current use() clause.
I may be in a minority of one on that point, though, for all I know.
The other concern is that this introduces a whole new realm of possible behaviors...
That's kind of where the closure thought came from - it seemed a very close analogue, so having one syntax for both feels natural. Outside of those cases, though, there's no reason it should mean anything, just as $this->foo or self::$foo doesn't mean anything outside a class. In fact, it could be spelled capture::$foo or $scope->foo rather than just using new punctuation, if we wanted to encourage that analogy.
Regards, -- Rowan Tommins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php