Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69809 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93204 invoked from network); 23 Oct 2013 17:50:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2013 17:50:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 198.187.29.239 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 198.187.29.239 imap1-1.ox.registrar-servers.com Received: from [198.187.29.239] ([198.187.29.239:50399] helo=imap1-1.ox.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/E3-10840-D6C08625 for ; Wed, 23 Oct 2013 13:50:37 -0400 Received: from localhost (localhost [127.0.0.1]) by oxmail.registrar-servers.com (Postfix) with ESMTP id EB7AB200087 for ; Wed, 23 Oct 2013 13:50:34 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap1.ox.registrar-servers.com Received: from oxmail.registrar-servers.com ([127.0.0.1]) by localhost (imap1.ox.registrar-servers.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id AhycPJggYLgh for ; Wed, 23 Oct 2013 13:50:34 -0400 (EDT) Received: from [192.168.0.200] (unknown [94.3.245.95]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 83510200081 for ; Wed, 23 Oct 2013 13:50:34 -0400 (EDT) Message-ID: <52680C60.7080305@ajf.me> Date: Wed, 23 Oct 2013 18:50:24 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:25.0) Gecko/20100101 Thunderbird/25.0 MIME-Version: 1.0 To: PHP internals Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Proposal: Implement FR #7930 (list() constructor reference assignment) From: ajf@ajf.me (Andrea Faulds) Good evening everyone, I have a simple suggestion for a feature addition, which I have already implemented. Over 13 years ago, someone suggested adding support for assigning by reference in list(), with the following syntax: $arr = [1, 2] list(&$a, $b) = $arr; Which would be equivalent to: $a = &$arr[0]; $b = $arr[2]; Their request is here: https://bugs.php.net/bug.php?id=6768 It seemed like a useful feature, so I implemented it. The syntax is a little unusual, in that normally you do $a = &$b, and with list() you'd do list(&$a) = [$b], but I don't think there's a better syntax for it that allows you to set some variables as references, but not all. The patch is here: https://github.com/TazeTSchnitzel/php-src/compare/ListByReference If people think it is useful, I'll write an RFC soon. Thanks, -- Andrea Faulds http://ajf.me/