rfc:arrow_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:arrow_functions [2017/01/23 22:07] – bwoebi | rfc:arrow_functions [2018/06/28 14:35] (current) – Withdraw levim | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ach ====== PHP RFC: Arrow Functions ====== | + | ====== PHP RFC: Arrow Functions ====== |
* Version: 1.3 | * Version: 1.3 | ||
* Date: 2016-08-14 | * Date: 2016-08-14 | ||
* Author: Levi Morrison < | * Author: Levi Morrison < | ||
* Author: Bob Weinand < | * Author: Bob Weinand < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
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 ==== | ||
Arrow functions have no ambiguities, | Arrow functions have no ambiguities, | ||
+ | ==== Backward Incompatible Changes ==== | ||
+ | Unfortunately the '' | ||
- | ===== Examples ===== | + | Ilija Tovilo analyzed the top 1,000 PHP repositories on GitHub to find usages of '' |
- | ==== Snippets | + | ==== Patches and Tests ==== |
+ | An implementation with tests can be found here: https:// | ||
+ | |||
+ | ==== Voting ==== | ||
+ | Voting will be a simple Yes/No that requires 2/3 or more of the votes to be " | ||
+ | |||
+ | ----- | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | ----- | ||
+ | |||
+ | ===== Examples ===== | ||
Taken from [[https:// | Taken from [[https:// | ||
Line 109: | Line 143: | ||
}</ | }</ | ||
- | ==== Longer Examples ==== | + | ----- |
- | The following | + | The following |
< | < | ||
Line 131: | Line 165: | ||
</ | </ | ||
- | ===== Future Scope ===== | + | ===== Future Scope: Multi-Statement Bodies |
- | + | ||
- | ==== Multi-Statement Bodies ==== | + | |
Some languages permit multi-statement closures with a syntax like: | Some languages permit multi-statement closures with a syntax like: | ||
Line 147: | 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. | ||
- | |||
- | ===== Backward Incompatible Changes ===== | ||
- | Unfortunately the '' | ||
- | |||
- | ===== Patches and Tests ===== | ||
- | An implementation with tests can be found here: https:// | ||
- | |||
- | ===== Voting ===== | ||
- | Voting will be a simple Yes/No that requires 2/3 or more of the votes to be " | ||
- | |||
- | ----- | ||
- | |||
- | <doodle title=" | ||
- | * Yes | ||
- | * No | ||
- | </ | ||
rfc/arrow_functions.1485209232.txt.gz · Last modified: 2017/09/22 13:28 (external edit)