Re: Allow Iterator to be used with current, next, reset,key functions
| From: | Andrea Faulds | Date: | Mon, 31 Oct 2016 13:58:46 +0000 |
| Subject: | Re: Allow Iterator to be used with current, next, reset,key functions | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96672@lists.php.net to get a copy of this message | ||
Hi Nikita,
Nikita Popov wrote:
On Fri, Oct 28, 2016 at 2:43 PM, Levi Morrison <levim@php.net> wrote: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/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.