On Tue, Oct 20, 2020, at 1:19 PM, 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 > > Hopefully I made a decent enough case for it. It's entirely a > convenience factor, but I think for many OOP cases (getter methods and > factored out operations) and functional cases (where functions should > generally be a single expression conceptually) it does make the code > nicer, more compact, and more readable. > > *dons flame retardant suit*
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. I can see good arguments for either, and in the end don't care all that much. My main concern was that `function` was easier to implement, but Sara graciously offered an alternate patch that uses `fn` instead. I'll make a PR out of that sometime later today. If we feel it's highly bikeshedable I'm happy to make that a secondary vote, or if a clear consensus emerges either way before then we can go with whatever that is. I think I moderately prefer `function` for visual consistency, especially inside a class, but it's not a hill I feel like being moderately injured on. :-) --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php