rfc:list_reference_assignment
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
rfc:list_reference_assignment [2016/12/31 18:29] – bp1222 | rfc:list_reference_assignment [2017/01/04 16:05] – bp1222 | ||
---|---|---|---|
Line 82: | Line 82: | ||
(notice here that the reference exists on '' | (notice here that the reference exists on '' | ||
- | The 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 & before the rvar, not the lvar, but the advantage here is that you can reference assign some, but not all of the variables in list(). | ||
- | The RFC also takes into account the possibility of objects being the lval of the assignment implementing ArrayAccess. | + | 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. | ||
<code php> | <code php> | ||
class RefArr implements ArrayAccess { | class RefArr implements ArrayAccess { | ||
Line 127: | Line 128: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | None Presently | + | ==== Both Syntax ==== |
+ | 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: | ||
+ | <file php> | ||
+ | <?php | ||
+ | $array = [1, 2, 3]; | ||
+ | list(& | ||
+ | </ | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== |
rfc/list_reference_assignment.txt · Last modified: 2017/12/09 12:43 by nikic