Hi Arnaud, Arnaud Le Blanc <arnaud...@gmail.com> wrote: > > Following your comment, I have clarified a few things in the "Auto-capture > semantics" section. This includes a list of way in which these effects can be > observed. These are really marginal cases that are not relevant for most > programs.
Cool, thanks. > Unfortunately, Arrow Functions already auto-capture today, so requiring a > `use(*)` to enable auto-capture would be a breaking change. I think there are two things that making this conversation be more adversial than it could be otherwise: 1. Some people really want implicit auto-capture, while others are deeply fearful of it. That comes more from the experience people have from writing/reading different types of code leading them to have different aesthetic preferences. Trying to persuade people their lived experience is wrong, is hard. 2. The current situation of having to list all variables is kind of annoying when it doesn't provide much value e.g. for stuff like: function getCallback($foo, $bar, $quux) { return function($x) use ($foo, $bar, $quux) { return $quux($foo, $bar, $x); } } Where the code that returns the closure is trivial having to list out the full of captured variables does feel tedious, and doesn't provide any value. I realise it's annoying when people suggest expanding the scope of an RFC, however...how would you feel about adding support for use(*) to the current 'long closures'? That way, people could choose between: * Explicit capture of individual variables: function($x) use ($foo, $bar, $quux) {...} * Explicit capture of all relevant variables: function($x) use (*) {...} * Implicit capture of all relevant variables, and fewer letters: fn($x) {...} People who don't want implicit capture would be able tell their code quality analysis tools to warn on any use of short closures (or possibly better, warn when a variable has been captured). People who do want implicit capture can use the short closures which always have implicit capture. cheers Dan Ack -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php