Re: Re: [RFC][Discuss] Arrow Functions

From: Date: Tue, 31 Jan 2017 10:23:33 +0000
Subject: Re: Re: [RFC][Discuss] Arrow Functions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-98067@lists.php.net to get a copy of this message
On 31/01/17 05:53, Stephen Reay wrote: > Hi Andrea, All, > >> On 31 Jan 2017, at 08:12, Andrea Faulds <ajf@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. Yes, I also think that keeping the function keyword would be better. > > 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. Wouldn't there be just too many existing closures, which do not use use but (maybe) expect a clean scope? -- Regards, Mike

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#98067) next »