Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96672 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15312 invoked from network); 31 Oct 2016 13:58:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Oct 2016 13:58:51 -0000 X-Host-Fingerprint: 137.50.157.117 oa-edu-157-117.wireless.abdn.ac.uk Received: from [137.50.157.117] ([137.50.157.117:17659] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/BD-25911-91E47185 for ; Mon, 31 Oct 2016 08:58:51 -0500 Message-ID: <62.BD.25911.91E47185@pb1.pair.com> To: internals@lists.php.net References: <44244cfd-c8ad-e0a9-4e70-380a8a8c940c@syberisle.net> Date: Mon, 31 Oct 2016 13:58:46 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 137.50.157.117 Subject: Re: [PHP-DEV] Allow Iterator to be used with current, next, reset,key functions From: ajf@ajf.me (Andrea Faulds) Hi Nikita, Nikita Popov wrote: > On Fri, Oct 28, 2016 at 2:43 PM, Levi Morrison wrote: >> >> I can't seem to recall specifics anymore but I do believe some people >> would greatly prefer to remove the internal array pointer for >> iteration and deprecate these functions. Maybe someone else can >> remember more? Nikita and Bob, maybe? >> > > Yeah, I'm one of those people. In PHP 7 the most important user of the IAP, > foreach, was switched to use a more robust mechanism. I believe that at > this point, the concept of an internal array pointer has outlived its > usefulness and we should be working toward removing any APIs that publicly > expose it, including each and the next/current/key family of functions. I > will propose to deprecate each() in particular for PHP 7.2, because it is > both more problematic and more useless than the others, but I'd like to see > the others go away in the long term as well. If people want fine-grained > control over array iteration, they should use an external iterator (aka > ArrayIterator), not an internal one. I'm sure I've suggested this before, but couldn't we drop the IAP without getting rid of these functions? They could maintain their own map of arrays to positions (effectively emulating the IAP), for example. Thanks. -- Andrea Faulds https://ajf.me/