On 21/10/2020 21:53, Larry Garfield wrote:
A while back, Nikita mentioned that it should now be easy to offer an
abbreviated syntax for functions that are just a single expression.  I
decided to take a crack at it and it turns out he was right.  I thus
offer this RFC:

https://wiki.php.net/rfc/short-functions


I like it. It fits nicely with my mental model of arrow functions as being special syntax for "functionising" a single expression. It may appeal less to people who see arrow functions as "the better way to write closures", and are hoping to extend them with full procedural bodies.


There's been some discussion on the PR that I'm looping back here for completeness, mainly about 
using "function" vs "fn" for short named functions.


You could list that under Open Issues on the RFC.

It occurred to me recently that maybe we could make "function" and "fn" synonyms everywhere, i.e. make both "$double = function($x) => $x *2;" and "$double = fn($x) use ($x) { return $x *2; };" valid. I'm not sure if that's desirable, or even if there's a reason it can't be done, but it would mean you don't have to make a decision on this RFC...


Regards,

--
Rowan Tommins (né Collins)
[IMSoP]

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

Reply via email to