Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60639 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57453 invoked from network); 21 May 2012 21:14:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 May 2012 21:14:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:48957] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/77-16352-520BABF4 for ; Mon, 21 May 2012 17:14:14 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id B1750700044E; Mon, 21 May 2012 22:14:10 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id fli6ue9z4u9I; Mon, 21 May 2012 22:14:10 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 1F1B5700049B; Mon, 21 May 2012 22:14:10 +0100 (WEST) Received: from damnation (damnation-air.nl.lo.geleia.net [IPv6:2001:470:94a2:4:7d06:1af1:ea64:2d52]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 8EF1D2005285; Mon, 21 May 2012 22:14:08 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "internals@lists.php.net" , "Richard Lynch" References: <478d25fa5ff481b470bd07c7ce627e03.squirrel@www.l-i-e.com> Date: Mon, 21 May 2012 23:14:05 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: <478d25fa5ff481b470bd07c7ce627e03.squirrel@www.l-i-e.com> User-Agent: Opera Mail/11.64 (Win32) Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] array_part() From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") First, I'd like to announce the native implementation is available on github: https://github.com/cataphract/php-src/compare/array_part Please review this feature BEFORE voting starts. Unless something comes up that has to be dealt with until then, I want to start voting on Monday, 28th May. Now my answer to Richard: On Mon, 21 May 2012 21:30:24 +0200, Richard Lynch wrote: > On Mon, May 14, 2012 9:03 am, Gustavo Lopes wrote: >> * array_slice() can preserve keys, array_part() cannot because when >> collapsing levels this would mean the possibility of overwriting >> elements. > > A predictable LIFO or FIFO for any collapsed keys would be reasonable, > and probably not much more work to implement. > > By LIFO I mean that the last value to be put under a key would "win" I > think that would be the most natural. > Such a behavior would be possible and would not be difficult to implement. However, it raises questions that are not easy to answer like: - should it keep the first or the last keys? Or perhaps it could instead collect all the elements under a new array. - should the behavior for numeric keys differ from that of string keys (perhaps in a array_merge way?) Since the path to add this behavior in the future is straightforward (add another optional argument, like in array_slice), not including it causes little damage in terms of future growth. On the other hand, my hope is that limiting the current design decisions to a easy subset may allow this to be merged rapidly. -- Gustavo Lopes