On Mon, Oct 31, 2016 at 11:27 AM, Larry Garfield <la...@garfieldtech.com> wrote:
> On 10/31/2016 11:26 AM, Alice Wonder wrote:
>>
>> On 10/30/2016 10:19 AM, Rowan Collins wrote:
>>
>>>
>>> - deprecate reset(), end(), each(), and key()
>>> - introduce array_first(), array_last(), array_first_key() and
>>> array_last_key()
>>> - document replacements for whatever other use cases we can find
>>> examples of
>>>
>>
>> As a user I certainly like those names better. Semantic function names are
>> a definite win in my view.
>
>
>
> Question: Now that we have "iterable" as a type, should we be adding more
> array-specific functions or should such operations be designed, and named,
> to operate on any iterable?  (first(), first_key(), etc.)

At least for last and last-key I do not think we should make them work
with any iterable. My reasoning is that we do not want to consume the
iterator for them because many iterators are not rewindable (such as
generators). The first and first-key routines should generally work
because `rewind(); valid(); current(); rewind();` doesn't contain a
`next()` call.

Rewinding without iterating works for generators: https://3v4l.org/O7ZKO
Rewinding after a next() call: https://3v4l.org/QI434

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to