Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8184 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99460 invoked by uid 1010); 26 Feb 2004 20:07:56 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 99363 invoked by uid 1007); 26 Feb 2004 20:07:56 -0000 Message-ID: <20040226200755.99362.qmail@pb1.pair.com> To: internals@lists.php.net Date: Thu, 26 Feb 2004 19:58:49 +0000 References: <20040226160254.4324.qmail@pb1.pair.com> <1051368455281.20040226204516@marcus-boerger.de> Lines: 31 Organization: Stutchbury User-Agent: KNode/0.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Posted-By: 62.49.23.238 Subject: Re: [PHP-DEV] Iterator Class/foreach Logic Flaw? From: philip@stutchbury.com (Philip Fletcher) Thanks Marcus Looking at the documentation, the comments and method name (for hasMore()) do not have the same meaning - the comment is saying 'does the current element exist?' and the method name says 'are there any more elements?'. This makes the api very ambiguous - hasMore() and isValid() have very specific meaning in many languages wrt iterators. Whilst I appreciate adding an isValid() method to the Iterator interface is not trivial (and I am loath to suggest a change this close to PHP RC phase), but it is surely better to have an un-ambiguous api on release - especially after all the clamouring for an interface implementation :) Regards Philip Marcus Boerger wrote: > Hello Philip, > > have a look at it's dokumentation: ext/spl/spl.php > there you'll find that hasMore() needs to be checked before an access to > key() or current() can be done. Hence it's meaning is somewhat like > isValid(). > > regards > marcus >