FAQ
Good evening again,

Previously I wrote to this mailing list about my proposal to add
reference assignment to list() with a new syntax ("[PHP-DEV] Proposal:
Implement FR #7930 (list() constructor reference assignment)"). I have
now opened an RFC:

https://wiki.php.net/rfc/list_reference_assignment

In brief, this allows you to write this:

$array = [1, 2];
$a = $array[0];
$b = &$array[1];

Like this instead:

$array = [1, 2];
list($a, &$b) = $array;

Reference assignments with list() work just like normal assignments, and
you can still skip variables, use nested list()s, and use list() in
foreach as usual.

There is a patch with a passing test, however a memory leak bug was
found (thanks Nikita!), and so the patch can't be considered complete or
final yet. I'm something of a novice at debugging PHP code at the
moment, so any help fixing that would be appreciated, but I will try to
fix it when I have more time.

The patch is here: https://bugs.php.net/bug.php?id=6768

The RFC has been added to the list in Under Discussion.

Any thoughts, suggestions, etc. appreciated.

Regards,
--
Andrea Faulds
http://ajf.me/

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
groupphp-internals @
categoriesphp
postedOct 24, '13 at 10:14p
activeMay 15, '14 at 7:12p
posts2
users1
websitephp.net

1 user in discussion

Andrea Faulds: 2 posts

People

Translate

site design / logo © 2022 Grokbase