rfc:list_reference_assignment
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:list_reference_assignment [2017/01/04 16:05] – bp1222 | rfc:list_reference_assignment [2017/09/22 13:28] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 6: | Line 6: | ||
* Original Date: 2013-10-24 | * Original Date: 2013-10-24 | ||
* Original Author: Andrea Faulds, ajf@ajf.me | * Original Author: Andrea Faulds, ajf@ajf.me | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 26: | Line 26: | ||
$a = $array[0]; | $a = $array[0]; | ||
$b =& $array[1]; | $b =& $array[1]; | ||
+ | </ | ||
+ | |||
+ | <code php> | ||
+ | /* Note; []= syntax works the same, so the following is functionally equivalent to the example */ | ||
+ | [$a, &$b] = $array; | ||
</ | </ | ||
Line 83: | Line 88: | ||
- | The predominant advantage of adding support for this is that it allows you to use reference assignment for multiple variables at once, which is not currently possible. The syntax here is different from the traditional assignment syntax which places the ''&'' | + | The predominant advantage of adding support for this is that it allows you to use reference assignment for multiple variables at once, which is not currently possible. The syntax here is different from the traditional assignment syntax which places the ''&'' |
The RFC also takes into account the possibility of objects being the r-val of the assignment implementing ArrayAccess. | The RFC also takes into account the possibility of objects being the r-val of the assignment implementing ArrayAccess. | ||
Line 127: | Line 132: | ||
Maybe, I don't know enough about opcache to say if changing current ops by adding an extended value would impact. | Maybe, I don't know enough about opcache to say if changing current ops by adding an extended value would impact. | ||
- | ===== Open Issues | + | ===== Proposed Voting Choices |
- | ==== Both Syntax ==== | + | Voting starts on 2017-02-06 17:30 UTC and closes on 2017-02-22 20:00 UTC |
- | The proposal follows the syntactic choice in allowing you to specify to each element in the list() which should be referenced into the target array. | + | |
- | <file php> | + | |
- | <?php | + | |
- | $array = [1, 2, 3]; | + | |
- | list($a, $b, $c) =& $array; | + | |
- | </ | + | |
- | Which would be identical to proposed syntax: | + | 2/3 Vote Required |
- | <file php> | + | Vote Yes to allow reference assignments as part of list() |
- | <?php | + | Vote No to maintain current functionality |
- | $array = [1, 2, 3]; | + | |
- | list(&$a, &$b, &$c) = $array; | + | |
- | </ | + | |
- | ===== Proposed Voting Choices ===== | + | <doodle title=" |
- | Will require 2/3 | + | * Yes |
+ | * No | ||
+ | </doodle> | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | * Working Implementation: | + | * Working Implementation: |
* Language Spec: https:// | * Language Spec: https:// | ||
rfc/list_reference_assignment.txt · Last modified: 2017/12/09 12:43 by nikic