rfc:arrow_functions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
rfc:arrow_functions [2017/01/30 17:50]
levim Pointless revision to get previous revision number
rfc:arrow_functions [2017/09/22 13:28]
127.0.0.1 external edit
Line 63: Line 63:
 ==== Type Declarations ==== ==== Type Declarations ====
 This RFC does support type declarations for parameters and return types. This issue was noted multiple times on the mailing list during the short closures RFC as something that bothered voters. Therefore this RFC permits them but the authors discourage their general use in arrow functions. This RFC does support type declarations for parameters and return types. This issue was noted multiple times on the mailing list during the short closures RFC as something that bothered voters. Therefore this RFC permits them but the authors discourage their general use in arrow functions.
 +
 +Here are some examples to show the syntax:
 +
 +<PHP>
 +fn (array $x) => $x
 +fn (): int => 42
 +</​PHP>​
  
 ==== References ==== ==== References ====
-Parameters and return values can be passed/​returned by reference. As mentioned elsewhere, implicitly bound variables will be bound //by value// and not //by reference//​.+Parameters and return values can be passed/​returned by reference. As mentioned elsewhere, implicitly bound variables will be bound //by value// and not //by reference//​. ​References go in the usual places: 
 + 
 +<​PHP>​ 
 +fn &(array &$xs) => $xs 
 +</​PHP>​
  
 ==== Static Arrow Functions ==== ==== Static Arrow Functions ====
Line 75: Line 86:
 Unfortunately the ''​fn''​ keyword must be a full keyword and not just a reserved function name; this is to break the ambiguities with ''<​nowiki>​=></​nowiki>''​ for array and yield keys. Unfortunately the ''​fn''​ keyword must be a full keyword and not just a reserved function name; this is to break the ambiguities with ''<​nowiki>​=></​nowiki>''​ for array and yield keys.
  
-Ilija Tovilo analyzed the top 1,000 PHP repositories on GitHub to find usages of ''​fn''​. [The gist](https://​gist.github.com/​morrisonlevi/​473a7e0cb6e59c830224b1c71b8da28cprovides more information,​ but the rough findings are that all known existing usages of ''​fn''​ are in tests except one case where it is a namespace segment.+Ilija Tovilo analyzed the top 1,000 PHP repositories on GitHub to find usages of ''​fn''​. [[https://​gist.github.com/​morrisonlevi/​473a7e0cb6e59c830224b1c71b8da28c|The gist]] ​provides more information,​ but the rough findings are that all known existing usages of ''​fn''​ are in tests except one case where it is a namespace segment.
  
 ==== Patches and Tests ==== ==== Patches and Tests ====
rfc/arrow_functions.txt · Last modified: 2018/06/28 14:35 by levim