Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] [RFC][Discussion] - list() reference syntax

Posted by David Walker 
David Walker
[PHP-DEV] [RFC][Discussion] - list() reference syntax
December 31, 2016 07:30AM
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
David Walker
[PHP-DEV] Fwd: [RFC][Discussion] - list() reference syntax
January 11, 2017 04:50PM
[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
Andrea Faulds
[PHP-DEV] Re: [RFC][Discussion] - list() reference syntax
January 11, 2017 11:20PM
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/

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
On Wed, Jan 11, 2017 at 3:15 PM Andrea Faulds <[email protected]> wrote:

> 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
David Walker
[PHP-DEV] Re: [RFC][Discussion] - list() reference syntax
January 30, 2017 10:20PM
On Wed, Jan 11, 2017 at 8:43 AM David Walker <[email protected]> wrote:

> [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
Sorry, only registered users may post in this forum.

Click here to login