Marcio Almada wrote on 30/09/2015 15:49:
That's not to say that automatic capture is an absolute blocker, but I think
>"the internals community is divided on it" is a reasonable summary.
>
That's the part I couldn't comprehend in the discussion. Auto import
is basically the most interesting reason to have short closures on
PHP.
It's also the biggest departure from existing PHP semantics - PHP's
scoping rules are remarkably simple compared to other languages:
everything is local unless qualified. No scope chains like JS, no "my"
and "our" like Perl, no short-hand references to properties of "this"
like Java, etc. "use", "global", and "static" can all be seen as
explicitly importing variables into that local scope.
Breaking that rule is something that needs to be considered very
carefully, and is a lot more than a minor detail of syntax.
I note that C++11, although it has a very compact (and keyword-less)
lambda syntax, still requires an explicit list of captured variables;
unfortunately, we can't just copy that syntax either, because we've used
[$var] for array construction. But it does show that "short closures"
and "auto-capture closures" are two different features; we could save up
to 17 characters without changing behaviour if we could eliminate the
keywords "function", "use", and "return".
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php