Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8271 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31053 invoked by uid 1010); 1 Mar 2004 14:04:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 31029 invoked from network); 1 Mar 2004 14:04:00 -0000 Received: from unknown (HELO mail.appliedsec.com) (69.17.65.231) by pb1.pair.com with SMTP; 1 Mar 2004 14:04:00 -0000 Received: from appliedsec.com (localhost.applied.sec [127.0.0.1]) by mail.appliedsec.com (Postfix) with ESMTP id B17E778C1B; Mon, 1 Mar 2004 09:00:36 -0500 (EST) Message-ID: <404342CE.5040202@appliedsec.com> Date: Mon, 01 Mar 2004 09:03:58 -0500 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030807 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andrei Zmievski , helly@php.net Cc: Philip Fletcher , internals@lists.php.net References: <20040226160254.4324.qmail@pb1.pair.com> <1051368455281.20040226204516@marcus-boerger.de> <20040226200755.99362.qmail@pb1.pair.com> <20040226204440.GB3900@hyperion.gravitonic.com> In-Reply-To: <20040226204440.GB3900@hyperion.gravitonic.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Iterator Class/foreach Logic Flaw? From: hans@appliedsec.com (Hans Lellelid) Hi Marcus, Andrei Zmievski wrote: > On Thu, 26 Feb 2004, Philip Fletcher wrote: > >>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. > > > I agree. The semantics are fairly different. Let's not confuse them. > I also agree strongly with the need for this to get fixed before PHP goes to release. IMO the current hasMore() is very misleading and has the result that people can't intuitively use it outside of the foreach() context. Whether the method is called isValid() or something else that makes sense is less important to me, but providing an intuitive interface that won't leave code users scratching their heads or submitting bug reports for what appears to be faulty implementing iterator logic is really important. BTW, Iterators are awesome(!), and it's only because they are so awesome & everyone will use them that I think this is important to address before release. Thanks, Hans