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

From: Date: Tue, 31 Jan 2017 04:53:32 +0000
Subject: Re: Re: [RFC][Discuss] Arrow Functions
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-98061@lists.php.net to get a copy of this message
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. 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

« previous php.internals (#98061) next »