# [RFC][Discussion] - list() reference syntax

- Thread: https://externals.io/message/97496
- Original archive: https://news-web.php.net/php.internals/97496
- Started by David Walker on 2016-12-31T06:21:15+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #97496 — David Walker — 2016-12-31T06:21:15+00:00

URL: https://externals.io/message/97496#97496

Hi All,

I had mentioned the other day my desire to look at, and attempt
implementation of allowing by-reference assignment within list()'s.  Andrea
had created an RFC for this purpose 2+years ago, but withdrew it due to
problems with implementation with the parsing/compiler of PHP 5.  I've
taken a shot at implementing this feature within PHP7 and have commandeered
the RFC and would like to re-open it for discussion.

I've attached to the RFC my current implementation which seems to be
working in the cases I can think of.  I'd be interested to hear from the
community about if this feature is still desirable, and if so, if there are
list() cases that I haven't thought about yet for test cases.

RFC (sorry for awkward formatting, not sure if the issues with links in
messages & mailinglist are fixed yet):
wiki php net/rfc/list_reference_assignment

Cheers
--
Dave

---

## #97689 — David Walker — 2017-01-11T15:43:25+00:00

URL: https://externals.io/message/97496#97689 · In reply to: #97496

[Sorry if this is a second time you get this, but email issues and all]

Hi All,

I had mentioned the other day my desire to look at, and attempt
implementation of allowing by-reference assignment within list()'s.  Andrea
had created an RFC for this purpose 2+years ago, but withdrew it due to
problems with implementation with the parsing/compiler of PHP 5.  I've
taken a shot at implementing this feature within PHP7 and have commandeered
the RFC and would like to re-open it for discussion.

I've attached to the RFC my current implementation which seems to be
working in the cases I can think of.  I'd be interested to hear from the
community about if this feature is still desirable, and if so, if there are
list() cases that I haven't thought about yet for test cases.

RFC (sorry for awkward formatting, not sure if the issues with links in
messages & mailinglist are fixed yet):
http://wiki.php.net/rfc/list_reference_assignment

Cheers
--
Dave

---

## #97704 — Andrea Faulds — 2017-01-11T22:14:53+00:00

URL: https://externals.io/message/97496#97704 · In reply to: #97496

Hi Dave,

Regarding the =& open issue in the RFC, I don't think the =& syntax 
makes sense to me. The thing on the right-hand side of a list() 
assignment is the array, not its values. It makes no difference for the 
purposes of assigning from its values if the array is a reference or 
not, so I'd expect the & here to do nothing at all. So, having the &s 
only on the left-hand side makes more sense to me. I think supporting =& 
would be a potential source of confusion.

On a different note, the RFC doesn't mention support for the shorthand 
list() syntax introduced in 7.1 (i.e. `[&$a, &$b, &$c] = $arr;`). Since 
it shares its implementation with list(), I assume it is indeed 
supported, but you should probably explicitly whether or not it is, for 
clarity's sake.

Thanks for your work on this! I'm glad to see it revived. :)

-- 
Andrea Faulds
https://ajf.me/

---

## #97710 — David Walker — 2017-01-11T22:42:46+00:00

URL: https://externals.io/message/97496#97710 · In reply to: #97704

> Regarding the =& open issue in the RFC, I don't think the =& syntax
> makes sense to me. The thing on the right-hand side of a list()
> assignment is the array, not its values. It makes no difference for the
> purposes of assigning from its values if the array is a reference or
> not, so I'd expect the & here to do nothing at all. So, having the &s
> only on the left-hand side makes more sense to me. I think supporting =&
> would be a potential source of confusion.
>

Duly noted.  I too would prefer not to implement it as well, keeping just
one supported syntax.  Although, since both syntaxes were raised as
potential implementations in the bugs I thought it would be something to at
least ask everyone to consider.  Better to raise the subject and have
everyone concur not to do it, than to ignore it, imo.  Going forward, I
guess I'd like to know if anyone -would- want to support it.


> On a different note, the RFC doesn't mention support for the shorthand
> list() syntax introduced in 7.1 (i.e. `[&$a, &$b, &$c] = $arr;`). Since
> it shares its implementation with list(), I assume it is indeed
> supported, but you should probably explicitly whether or not it is, for
> clarity's sake.
>

Yup, you're right.  list() = and [] = do seem to follow the same
compilation/execution so there's no difference.  I'll make sure to note it
in the RFC just to note.

Cheers
--
Dave

---

## #98053 — David Walker — 2017-01-30T21:08:37+00:00

URL: https://externals.io/message/97496#98053 · In reply to: #97689

> [Sorry if this is a second time you get this, but email issues and all]
>
> Hi All,
>
> I had mentioned the other day my desire to look at, and attempt
> implementation of allowing by-reference assignment within list()'s.  Andrea
> had created an RFC for this purpose 2+years ago, but withdrew it due to
> problems with implementation with the parsing/compiler of PHP 5.  I've
> taken a shot at implementing this feature within PHP7 and have commandeered
> the RFC and would like to re-open it for discussion.
>
> I've attached to the RFC my current implementation which seems to be
> working in the cases I can think of.  I'd be interested to hear from the
> community about if this feature is still desirable, and if so, if there are
> list() cases that I haven't thought about yet for test cases.
>
> RFC (sorry for awkward formatting, not sure if the issues with links in
> messages & mailinglist are fixed yet):
> http://wiki.php.net/rfc/list_reference_assignment
>
> Cheers
> --
> Dave
>

I'd like to open this RFC to voting in the next week or so.  I know that I
had sent the notice for discussion during the list-serve problems earlier
this month, but there has been limited comment over the past couple weeks.
Unsure if that means there's little interest, or, just missed everyone, or
is perfect as is (!! well, we could hope right?).  So if there's any
discussion now's a good time, otherwise I'd like to open it to voting early
next week.

Cheers
--
Dave
