Hi Andrea, All,

> On 31 Jan 2017, at 08:12, Andrea Faulds <a...@ajf.me> wrote:
> 
> Is it necessary to introduce a new keyword, fn?
> 
> I think you'd get a similar benefit from:
> 
>    function($x) => $arr[$x]
> 
> Likewise, is it necessary to restrict auto-capture to the => syntax? Couldn't 
> we allow the following?
> 
>    function ($x) {
>        return $arr[$x];
>    }
> 

I agree that the `fn` keyword isn’t really necessary. I’ve never quite 
understood how arrow functions with implied returns etc are supposed to make 
for *more* readable code, but if they’re going to be part of the language 
please at least keep some consistency with regular closures.

In the case that regular closures got auto-capture, would a `use($foo, $bar, 
$baz)` segment on a closure still be honoured (i.e. disable auto-capture), and 
would it have any impact (positive or negative) on performance/memory usage? 
After several years of JS closure ‘fun’ I kind of like that with PHP you only 
inherit the variables you explicitly `use()` in closures.

Cheers

Stephen


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to