Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90688 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50113 invoked from network); 18 Jan 2016 02:07:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jan 2016 02:07:45 -0000 X-Host-Fingerprint: 90.212.141.145 unknown Received: from [90.212.141.145] ([90.212.141.145:2162] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E4/B4-20254-FE84C965 for ; Sun, 17 Jan 2016 21:07:43 -0500 Message-ID: To: internals@lists.php.net References: <3B.E6.32157.D3DFA965@pb1.pair.com> Date: Mon, 18 Jan 2016 02:07:40 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 90.212.141.145 Subject: Re: [PHP-DEV] [RFC] Allow specifying keys in list() From: ajf@ajf.me (Andrea Faulds) Hi Bishop, Bishop Bettini wrote: > On Sat, Jan 16, 2016 at 9:32 PM, Andrea Faulds wrote: > >> Hi everyone, >> >> Here's an RFC that would extend the syntax of list() to be more useful >> with associative arrays: >> >> https://wiki.php.net/rfc/list_keys >> >> Please read it and tell me your thoughts. >> > > Nice, Andrea, thanks! Destructuring is quite handy. > > I wonder if there is opportunity to include array gathering. Something > along the lines of: > > list ('foo' => $foo, ...$rest) = [ 'foo' => 1, 'bar' => 2, 'baz' => 3]; > assert $foo === 1; > assert $rest === [ 'bar' => 2, 'baz' => 3]; > > What do you think? That might be useful, and it's certainly intuitive. In languages with linked lists like Haskell, you can pattern-match the rest of a list, so there's a precedent. Though with linked lists it's an O(1) operation, while this is O(n). I don't think that should go into this RFC specifically, though, but it could be a future enhancement. Thanks! -- Andrea Faulds https://ajf.me/