Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69810 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95004 invoked from network); 23 Oct 2013 18:03:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2013 18:03:20 -0000 Authentication-Results: pb1.pair.com header.from=leverton@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=leverton@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.53 as permitted sender) X-PHP-List-Original-Sender: leverton@gmail.com X-Host-Fingerprint: 209.85.219.53 mail-oa0-f53.google.com Received: from [209.85.219.53] ([209.85.219.53:40471] helo=mail-oa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/44-10840-86F08625 for ; Wed, 23 Oct 2013 14:03:20 -0400 Received: by mail-oa0-f53.google.com with SMTP id n12so1230141oag.40 for ; Wed, 23 Oct 2013 11:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=MTL8BoZr3wuErB3cJt1w5XoO59tAMqxLacxrAzJMpZ0=; b=QbhmesGyhd9fqU8ujx0/boKHJRSSFKJ1G2iZrPizcZIe7dyo2hmK7W5TAwIt7RupN0 HjEusEkg7mknF4lFQYw8TDqPXteeMaczIIEux7NOQ2mmAJIa+8PAKLjl5/OndcFgxdeO tfV638P4/+5FShM4VRPMppraYDMp8geOlzzMZg/vd5tsoIp+g9JambcQ8uMZ3pIm9enQ 7vgHjTaKMq1rlYQ0LaPVk+1FOtvtcafyj9dTYAXIx62FQ55Em0y1sfTjRB4ZCS5k6w9q GCROQKyceOhkLa1TyDwOMLuHPr88t6Ag8QavOo/3u9Inm8F2J9pAxNN01xD+AcbTfD7s WDnw== MIME-Version: 1.0 X-Received: by 10.182.246.74 with SMTP id xu10mr2948862obc.23.1382551398047; Wed, 23 Oct 2013 11:03:18 -0700 (PDT) Received: by 10.182.77.68 with HTTP; Wed, 23 Oct 2013 11:03:18 -0700 (PDT) In-Reply-To: <52680C60.7080305@ajf.me> References: <52680C60.7080305@ajf.me> Date: Wed, 23 Oct 2013 13:03:18 -0500 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Proposal: Implement FR #7930 (list() constructor reference assignment) From: leverton@gmail.com (Matthew Leverton) Seems like a natural fit to me. Does it also work with the new foreach/list combo? foreach ($array as list(&$a, $b)) {} -- Matthew Leverton On Wed, Oct 23, 2013 at 12:50 PM, Andrea Faulds wrote: > 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/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >