Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99712 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48860 invoked from network); 3 Jul 2017 15:53:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2017 15:53:44 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 84.19.169.162 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 84.19.169.162 mail.experimentalworks.net Received: from [84.19.169.162] ([84.19.169.162:59462] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/24-15131-7886A595 for ; Mon, 03 Jul 2017 11:53:43 -0400 Received: from kuechenschabe.fritz.box (ppp-46-244-168-155.dynamic.mnet-online.de [46.244.168.155]) by mail.experimentalworks.net (Postfix) with ESMTPSA id 3F52B5DE53; Mon, 3 Jul 2017 17:53:40 +0200 (CEST) Message-ID: <1499097219.19635.57.camel@schlueters.de> To: Niklas Keller Cc: Andreas Hennings , PHP Internals Date: Mon, 03 Jul 2017 17:53:39 +0200 In-Reply-To: References: <1499095625.19635.52.camel@schlueters.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] "Reader" as alternative to Iterator From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) 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. > > Not really, Iterator::next() returns void, so could as well return > bool. Well, that story is a bit longer and I cut it short. Let's assume we remove valid and use next's return value. Then we don't know if the first element exists or not, as next is only called after the first iteration. An alternative might be using only current() but then we need a special, magic, return value to mark the end oder references. Both are bad. johannes