Re: [RFC][Discuss] Arrow Functions

From: Date: Sat, 04 Feb 2017 03:33:09 +0000
Subject: Re: [RFC][Discuss] Arrow Functions
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-98163@lists.php.net to get a copy of this message
> On Feb 3, 2017, at 9:06 PM, Stephen Reay <php-lists@koalephant.com> wrote: > > >> On 4 Feb 2017, at 07:25, Aaron Piotrowski <aaron@trowski.com> wrote: >> >> $callback = |int|float $x| => $x ** 2; > > Forget the parser, you're giving my eyes diabetes trying to read that. I absolutely agree that it's terrible… the point is that types (even potential future union types) can be used with short closures, but it certainly doesn't mean they should be. I don't think confusion with a non-existent and non-recommended way of coding should be a reason against a particular syntax. > As has been said before, PHP is relatively verbose compared to other languages. That makes it > slightly more characters to type, but it also makes it absolutely clear what is happening. Using function IMO makes it more likely to confuse a short closure with a regular closure. Reusing the function keyword with different semantics may result in some confusion. > As Niklas said, all ambiguity/clarity issues are solved by using "function", at the > cost of 6 characters. > > Suggesting that a search for arrow functions will be easier with <insert random character > here> and then using grep (which could also easily match arrow functions using > "function") as your example search seems odd to me. I never suggested this, Björn Larsson did. Any of the possibilities mentioned in this thread could easily be searched. Regards, Aaron Piotrowski

« previous php.internals (#98163) next »