Re: "Reader" as alternative to Iterator
| From: | Andreas Hennings | Date: | Mon, 03 Jul 2017 16:11:50 +0000 |
| Subject: | Re: "Reader" as alternative to Iterator | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-99716@lists.php.net to get a copy of this message | ||
On Mon, Jul 3, 2017 at 6:08 PM, Andreas Hennings <andreas@dqxtech.net> wrote:
> On Mon, Jul 3, 2017 at 5:53 PM, Johannes Schlüter
> <johannes@schlueters.de> wrote:
>> On Mo, 2017-07-03 at 17:32 +0200, Niklas Keller wrote:
>>
>>> > That distinction is the reason why next() and valid() are different
>>> > methods in iterators.
>
> I would rather say this is the reason why current() and valid() are
> different methods.
> A combination of ->current() and next() would not cause problems.
>
>>>
>>> Not really, Iterator::next() returns void, so could as well return
>>> bool.
Just so we are on the same page:
Changing the behavior of Iterator interface would be a BC break.
Introducing a new interface, and letting Generator implement it, would
not break anything.
(except for the possible nameclash, if the an interface with the same
name already exists in userland outside of a namespace)
I assume we already agree on this, and this was more of a thought experiment.