rfc:arrow_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:arrow_functions [2017/01/30 17:31] – levim | rfc:arrow_functions [2017/09/22 13:28] – external edit 127.0.0.1 | ||
---|---|---|---|
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 | ||
+ | </ | ||
+ | |||
+ | ==== References ==== | ||
+ | Parameters and return values can be passed/ | ||
+ | |||
+ | <PHP> | ||
+ | fn &(array &$xs) => $xs | ||
+ | </ | ||
+ | |||
+ | ==== Static Arrow Functions ==== | ||
+ | The implementation currently supports static closures, for example < | ||
==== Ambiguities ==== | ==== Ambiguities ==== | ||
Line 69: | Line 86: | ||
Unfortunately the '' | Unfortunately the '' | ||
- | Ilija Tovilo analyzed the top 1,000 PHP repositories on GitHub to find usages of '' | + | Ilija Tovilo analyzed the top 1,000 PHP repositories on GitHub to find usages of '' |
==== Patches and Tests ==== | ==== Patches and Tests ==== | ||
Line 87: | Line 104: | ||
===== Examples ===== | ===== Examples ===== | ||
- | |||
- | ==== Snippets ==== | ||
Taken from [[https:// | Taken from [[https:// | ||
Line 128: | Line 143: | ||
}</ | }</ | ||
- | ==== Longer Examples ==== | + | ----- |
- | The following | + | The following |
< | < | ||
Line 164: | Line 179: | ||
This RFC omitted this feature for these reasons. If arrow functions are accepted and become more common it may make sense to revisit this feature. | This RFC omitted this feature for these reasons. If arrow functions are accepted and become more common it may make sense to revisit this feature. | ||
+ |
rfc/arrow_functions.txt · Last modified: 2018/06/28 14:35 by levim