Re: [RFC] Arrow Functions

From: Date: Thu, 15 Oct 2015 19:50:00 +0000
Subject: Re: [RFC] Arrow Functions
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-88836@lists.php.net to get a copy of this message
Den 2015-10-03 kl. 01:17, skrev Levi Morrison:
I messaged the list about this feature before I had the RFC written up for it. The RFC[1] is slightly different from what I proposed in the previous thread, so please read the RFC to make sure you understand what is being proposed before replying here. Here's a small example:
     $y = 10;
     $result = array_map(function($x) => $x + $y, [1, 2, 3]);
     // $result is [11, 12, 13]
Thanks for people who have participated in conversation so far, as well as those who participated in Bob's short closures proposal as well. [1]: https://wiki.php.net/rfc/arrow_functions Well my comments are:
- By having => as operator we block future idea to remove function keyword in case limitation in parser is overcome. - Also suppose one would like to do a simple grep for all anonymous function in a project, having same as array key will require regexp search. - It would also be good is this RFC includes all required text instead referring to Bob's old one. - I also misses if default values are supported. - Not being able to overcome limitation is parser, seems like this RFC is a compromise for some developers... - For me as a userland developer I prefer Bob's old proposal but with added type hints, default values and requiring parenthesis for the single parameter case. r//Björn

« previous php.internals (#88836) next »