rfc:auto-capture-closure
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:auto-capture-closure [2022/07/01 09:57] – lbarnaud | rfc:auto-capture-closure [2022/07/16 09:43] (current) – lbarnaud | ||
---|---|---|---|
Line 5: | Line 5: | ||
* Author: Larry Garfield (larry@garfieldtech.com) | * Author: Larry Garfield (larry@garfieldtech.com) | ||
* Author: Arnaud Le Blanc (arnaud.lb@gmail.com) | * Author: Arnaud Le Blanc (arnaud.lb@gmail.com) | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 282: | Line 282: | ||
* In all other situations in which a variable is used, it is assumed that it is read | * In all other situations in which a variable is used, it is assumed that it is read | ||
- | This optimization is not applied to Arrow Functions. | + | This optimization is not applied to Arrow Functions |
==== Observable effects of capture ==== | ==== Observable effects of capture ==== | ||
Line 385: | Line 385: | ||
Existing function syntaxes continues to work precisely as they do now. Only new combinations are possible. | Existing function syntaxes continues to work precisely as they do now. Only new combinations are possible. | ||
- | ===== Unaffected PHP Functionality | + | ===== Future Scope ===== |
These are some possible future extensions, but the authors don't necessarily endorse them. | These are some possible future extensions, but the authors don't necessarily endorse them. | ||
Line 394: | Line 394: | ||
<code php> | <code php> | ||
- | $fn = fn() use($a, &$b) { | + | $fn = fn () use ($a, &$b) { |
}; | }; | ||
</ | </ | ||
- | One benefit of this syntax | + | One anticipated use-case |
- | This is not included in this RFC because it appeared to create confusion. | + | There are at least two possible variations of this extension. In one of them, the use list is merged with auto-capture, so that explicit uses and auto-capture |
- | + | ||
- | ==== Opt-in auto-capture on Anonymous Functions ==== | + | |
- | + | ||
- | It would be possible to add opt-in | + | |
- | + | ||
- | <code php> | + | |
- | $f = function() use (*) { | + | |
- | }; | + | |
- | </ | + | |
- | This is not included in this RFC because | + | This RFC initially proposed the first possibility. |
==== Optimize Arrow Functions ==== | ==== Optimize Arrow Functions ==== | ||
- | This RFC proposes an optimized auto-capture. It would be possible to apply this optimization to Arrow Functions as well. This would be a breaking change in some rare cases. | + | This RFC proposes an optimized auto-capture. It would be possible to apply this optimization to Arrow Functions as well, but this would be a breaking change in some rare cases. |
This is not included in this RFC because most Arrow Functions would not benefit from this. | This is not included in this RFC because most Arrow Functions would not benefit from this. | ||
- | ===== Proposed Voting Choices | + | ===== Vote ===== |
- | This is a simple Yes/No vote, requiring 2/3 to pass. | + | This is a simple Yes/No vote, requiring 2/3 to pass. Vote ends on 15 July 2022. |
rfc/auto-capture-closure.1656669470.txt.gz · Last modified: 2022/07/01 09:57 by lbarnaud